Skip to contentSkip to conversation

driver core: location: Check for allocations failure

PATCH New Dan Carpenter 1 participant 1 message May 5, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver core: location: Check for allocations failure

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

Fixes 6423d2951087 ("driver core: Add sysfs support for physical location of a device")
---
 drivers/base/physical_location.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/base/physical_location.c +2 -0
index 4c1a52ecd7f6..fbd9f9839e92 100644
@@ -24,6 +24,8 @@ bool dev_add_physical_location(struct device *dev)
 
 	dev->physical_location =
 		kzalloc(sizeof(*dev->physical_location), GFP_KERNEL);
+	if (!dev->physical_location)
+		return false;
 	dev->physical_location->panel = pld->panel;
 	dev->physical_location->vertical_position = pld->vertical_position;
 	dev->physical_location->horizontal_position = pld->horizontal_position;
Signature · 1 line
2.35.1