apple-properties.c (3b9274ea1c0279b369212ccd440c9d61efdfa562) | apple-properties.c (db8952e7094fde3a397321240d5d57ec111258d8) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * apple-properties.c - EFI device properties on Macs 4 * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de> 5 * 6 * Note, all properties are considered as u8 arrays. 7 * To get a value of any of them the caller must use device_property_read_u8_array(). 8 */ --- 32 unchanged lines hidden (view full) --- 41struct properties_header { 42 u32 len; 43 u32 version; 44 u32 dev_count; 45 struct dev_header dev_header[]; 46}; 47 48static void __init unmarshal_key_value_pairs(struct dev_header *dev_header, | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * apple-properties.c - EFI device properties on Macs 4 * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de> 5 * 6 * Note, all properties are considered as u8 arrays. 7 * To get a value of any of them the caller must use device_property_read_u8_array(). 8 */ --- 32 unchanged lines hidden (view full) --- 41struct properties_header { 42 u32 len; 43 u32 version; 44 u32 dev_count; 45 struct dev_header dev_header[]; 46}; 47 48static void __init unmarshal_key_value_pairs(struct dev_header *dev_header, |
49 struct device *dev, void *ptr, | 49 struct device *dev, const void *ptr, |
50 struct property_entry entry[]) 51{ 52 int i; 53 54 for (i = 0; i < dev_header->prop_count; i++) { 55 int remaining = dev_header->len - (ptr - (void *)dev_header); 56 u32 key_len, val_len, entry_len; 57 const u8 *entry_data; --- 54 unchanged lines hidden (view full) --- 112 113static int __init unmarshal_devices(struct properties_header *properties) 114{ 115 size_t offset = offsetof(struct properties_header, dev_header[0]); 116 117 while (offset + sizeof(struct dev_header) < properties->len) { 118 struct dev_header *dev_header = (void *)properties + offset; 119 struct property_entry *entry = NULL; | 50 struct property_entry entry[]) 51{ 52 int i; 53 54 for (i = 0; i < dev_header->prop_count; i++) { 55 int remaining = dev_header->len - (ptr - (void *)dev_header); 56 u32 key_len, val_len, entry_len; 57 const u8 *entry_data; --- 54 unchanged lines hidden (view full) --- 112 113static int __init unmarshal_devices(struct properties_header *properties) 114{ 115 size_t offset = offsetof(struct properties_header, dev_header[0]); 116 117 while (offset + sizeof(struct dev_header) < properties->len) { 118 struct dev_header *dev_header = (void *)properties + offset; 119 struct property_entry *entry = NULL; |
120 const struct efi_dev_path *ptr; |
|
120 struct device *dev; 121 size_t len; 122 int ret, i; | 121 struct device *dev; 122 size_t len; 123 int ret, i; |
123 void *ptr; | |
124 125 if (offset + dev_header->len > properties->len || 126 dev_header->len <= sizeof(*dev_header)) { 127 pr_err("invalid len in dev_header at %#zx\n", offset); 128 return -EINVAL; 129 } 130 131 ptr = dev_header->path; 132 len = dev_header->len - sizeof(*dev_header); 133 | 124 125 if (offset + dev_header->len > properties->len || 126 dev_header->len <= sizeof(*dev_header)) { 127 pr_err("invalid len in dev_header at %#zx\n", offset); 128 return -EINVAL; 129 } 130 131 ptr = dev_header->path; 132 len = dev_header->len - sizeof(*dev_header); 133 |
134 dev = efi_get_device_by_path((struct efi_dev_path **)&ptr, &len); | 134 dev = efi_get_device_by_path(&ptr, &len); |
135 if (IS_ERR(dev)) { 136 pr_err("device path parse error %ld at %#zx:\n", | 135 if (IS_ERR(dev)) { 136 pr_err("device path parse error %ld at %#zx:\n", |
137 PTR_ERR(dev), ptr - (void *)dev_header); | 137 PTR_ERR(dev), (void *)ptr - (void *)dev_header); |
138 print_hex_dump(KERN_ERR, pr_fmt(), DUMP_PREFIX_OFFSET, 139 16, 1, dev_header, dev_header->len, true); 140 dev = NULL; 141 goto skip_device; 142 } 143 144 entry = kcalloc(dev_header->prop_count + 1, sizeof(*entry), 145 GFP_KERNEL); --- 87 unchanged lines hidden --- | 138 print_hex_dump(KERN_ERR, pr_fmt(), DUMP_PREFIX_OFFSET, 139 16, 1, dev_header, dev_header->len, true); 140 dev = NULL; 141 goto skip_device; 142 } 143 144 entry = kcalloc(dev_header->prop_count + 1, sizeof(*entry), 145 GFP_KERNEL); --- 87 unchanged lines hidden --- |