linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] driver core: location: Check for allocations failure
@ 2022-05-05 10:32 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-05-05 10:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Won Chung
  Cc: Rafael J. Wysocki, linux-kernel, kernel-janitors

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

Fixes: 6423d2951087 ("driver core: Add sysfs support for physical location of a device")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/base/physical_location.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/base/physical_location.c b/drivers/base/physical_location.c
index 4c1a52ecd7f6..fbd9f9839e92 100644
--- a/drivers/base/physical_location.c
+++ b/drivers/base/physical_location.c
@@ -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;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-05 10:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-05 10:32 [PATCH] driver core: location: Check for allocations failure Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).