Skip to content

Commit 326a4b7

Browse files
aloktiwagregkh
authored andcommitted
net: marvell: prestera: fix NULL dereference on devlink_alloc() failure
[ Upstream commit a428e0d ] devlink_alloc() may return NULL on allocation failure, but prestera_devlink_alloc() unconditionally calls devlink_priv() on the returned pointer. This leads to a NULL pointer dereference if devlink allocation fails. Add a check for a NULL devlink pointer and return NULL early to avoid the crash. Fixes: 34dd171 ("net: marvell: prestera: Add basic devlink support") Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com> Acked-by: Elad Nachman <enachman@marvell.com> Link: https://patch.msgid.link/20251230052124.897012-1-alok.a.tiwari@oracle.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8bdafdf commit 326a4b7

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/net/ethernet/marvell/prestera/prestera_devlink.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ struct prestera_switch *prestera_devlink_alloc(struct prestera_device *dev)
387387

388388
dl = devlink_alloc(&prestera_dl_ops, sizeof(struct prestera_switch),
389389
dev->dev);
390+
if (!dl)
391+
return NULL;
390392

391393
return devlink_priv(dl);
392394
}

0 commit comments

Comments
 (0)