Skip to content

Commit c5dc2d8

Browse files
RandDeebgregkh
authored andcommitted
ssb: Fix potential NULL pointer dereference in ssb_device_uevent()
[ Upstream commit 789c171 ] The ssb_device_uevent() function first attempts to convert the 'dev' pointer to 'struct ssb_device *'. However, it mistakenly dereferences 'dev' before performing the NULL check, potentially leading to a NULL pointer dereference if 'dev' is NULL. To fix this issue, move the NULL check before dereferencing the 'dev' pointer, ensuring that the pointer is valid before attempting to use it. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Rand Deeb <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://msgid.link/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent fd841ee commit c5dc2d8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/ssb/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,13 @@ static int ssb_bus_match(struct device *dev, struct device_driver *drv)
341341

342342
static int ssb_device_uevent(const struct device *dev, struct kobj_uevent_env *env)
343343
{
344-
const struct ssb_device *ssb_dev = dev_to_ssb_dev(dev);
344+
const struct ssb_device *ssb_dev;
345345

346346
if (!dev)
347347
return -ENODEV;
348348

349+
ssb_dev = dev_to_ssb_dev(dev);
350+
349351
return add_uevent_var(env,
350352
"MODALIAS=ssb:v%04Xid%04Xrev%02X",
351353
ssb_dev->id.vendor, ssb_dev->id.coreid,

0 commit comments

Comments
 (0)