efi/apple-properties: Delete an error message for a failed memory allocation in unmarshal_devices()
Subsystems (2)
PATCH 1/1 efi/apple-properties: Delete an error message for a failed memory allocation in unmarshal_devices()
From: Markus Elfring <[email protected]>
Date: Tue, 13 Feb 2018 17:52:10 +0100
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/firmware/efi/apple-properties.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/efi/apple-properties.c +1 -3
@@ -158,10 +158,8 @@ static int __init unmarshal_devices(struct properties_header *properties) entry =kcalloc (dev_header->prop_count +1 ,sizeof (*entry),GFP_KERNEL ); -if (!entry) { -dev_err (dev,"cannot allocate properties\n" ); +if (!entry) goto skip_device; - }unmarshal_key_value_pairs (dev_header, dev, ptr, entry);if (!entry[0 ].name)
Signature · 1 line
2.16.1
Quoted 1 line · SF Markus Elfring
Omit an extra message for a memory allocation failure in this function.
[snip]
Quoted 4 lines
drivers/firmware/efi/apple-properties.c +0
-0@@ -158,10 +158,8 @@ static int __init unmarshal_devices(struct properties_header *properties)
drivers/firmware/efi/apple-properties.c static int __init unmarshal_devices(struct properties_header *properties) · line 165
Quoted 10 lines
drivers/firmware/efi/apple-properties.c +1
-3entry =kcalloc (dev_header->prop_count +1 ,sizeof (*entry),GFP_KERNEL ); -if (!entry) { -dev_err (dev,"cannot allocate properties\n" ); +if (!entry) goto skip_device; - }unmarshal_key_value_pairs (dev_header, dev, ptr, entry);if (!entry[0 ].name)
While the allocator does print an error when allocations fail, it may not be immediately apparent to the user what the *consequences* are. In this case, the consequence is that the device properties will not be available for consumption by drivers and they may fail to probe or behave in entirely unexpected ways. Hence I deliberately printed an error message here so that the user can make the connection between erratic behavior of drivers later on and the memory allocation error here.
You didn't cc me on your submission even though I'm the author of 99% of this file. Please make an effort prior to submission to identify interested parties.
Lukas
Quoted 5 lines · Lukas Wunner
Quoted 1 line · SF Markus Elfring
---
a/drivers/firmware/efi/apple-properties.cYou didn't cc me on your submission even though I'm the author of 99% of this file. Please make an effort prior to submission to identify interested parties.
If you want to receive patches for this file, even if you are not a maintainer or an upstream path, you should add yourself as a reviewer to the MAINTAINERS file like:
APPLE EFI PROPERTIES
R: Lukas Wunner <[email protected]>
F: drivers/firmware/efi/apple-properties.c
Re: efi/apple-properties: Checking error handling in unmarshal_devices()
In reply to Lukas WunnerQuoted 6 lines
While the allocator does print an error when allocations fail, it may not be immediately apparent to the user what the *consequences* are. In this case, the consequence is that the device properties will not be available for consumption by drivers and they may fail to probe or behave in entirely unexpected ways.
Would it make sense to indicate such a questionable software situation be any return code?
Quoted 3 lines
Hence I deliberately printed an error message here so that the user can make the connection between erratic behavior of drivers later on and the memory allocation error here.
Do you find this terse message really sufficient?
Can the mentioned properties be required for the desired system configuration?
Regards,
Markus