]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:10:16 +0000 (13:10 +0100)
commit8a4333b2818f0d853b43e139936c20659366e4a0
treeff3ef29836862e19324ab7d42016509484de2cfc
parentc4cde57c8affdcca5bcff53a1047e15d268bdca1
net: marvell: prestera: fix NULL dereference on devlink_alloc() failure

[ Upstream commit a428e0da1248c353557970848994f35fd3f005e2 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/marvell/prestera/prestera_devlink.c