diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2022-05-05 13:32:59 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-05-06 09:58:34 +0200 |
commit | bc443c31def574e3bfaed50cb493b8305ad79435 (patch) | |
tree | bd8f946c9f85a7fa2b36b45c5ae68649eb6fcc51 /drivers/base | |
parent | c3d438eeb5413111889edef10cb5fcc2c0fb8bc9 (diff) |
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YnOn28OFBHHd5bQb@kili
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/physical_location.c | 2 |
1 files changed, 2 insertions, 0 deletions
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; |