]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: marvell: prestera: fix NULL dereference on devlink_alloc() failure
authorAlok Tiwari <alok.a.tiwari@oracle.com>
Tue, 30 Dec 2025 05:21:18 +0000 (21:21 -0800)
committerJakub Kicinski <kuba@kernel.org>
Sun, 4 Jan 2026 17:38:55 +0000 (09:38 -0800)
commita428e0da1248c353557970848994f35fd3f005e2
tree10c2b555c9411e185a78398e80dff1701b5bdd9b
parentdbf8fe85a16a33d6b6bd01f2bc606fc017771465
net: marvell: prestera: fix NULL dereference on devlink_alloc() failure

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: 34dd1710f5a3 ("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>
drivers/net/ethernet/marvell/prestera/prestera_devlink.c