Commit bc443c31 authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

driver core: location: Check for allocations failure

Check whether the kzalloc() succeeds and return false if it fails.

Fixes: 6423d295 ("driver core: Add sysfs support for physical location of a device")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YnOn28OFBHHd5bQb@kiliSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c3d438ee
...@@ -24,6 +24,8 @@ bool dev_add_physical_location(struct device *dev) ...@@ -24,6 +24,8 @@ bool dev_add_physical_location(struct device *dev)
dev->physical_location = dev->physical_location =
kzalloc(sizeof(*dev->physical_location), GFP_KERNEL); kzalloc(sizeof(*dev->physical_location), GFP_KERNEL);
if (!dev->physical_location)
return false;
dev->physical_location->panel = pld->panel; dev->physical_location->panel = pld->panel;
dev->physical_location->vertical_position = pld->vertical_position; dev->physical_location->vertical_position = pld->vertical_position;
dev->physical_location->horizontal_position = pld->horizontal_position; dev->physical_location->horizontal_position = pld->horizontal_position;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment