mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 09:20:13 -04:00
net: phylink: correctly validate returned PCS in phylink_inband_caps
In phylink_inband_caps(), the PCS returned by mac_select_pcs is only
checked if NULL but mac_select_pcs can also return an error pointer.
This can cause a kernel panic as phylink_pcs_inband_caps() only checks
if passed PCS is not NULL and directly dereference ops from the phylink_pcs
struct.
Use the IS_ERR_OR_NULL macro to address both case where the returned
PCS can be NULL or an error pointer and prevent a kernel panic.
Cc: stable@vger.kernel.org
Fixes: df874f9e52 ("net: phylink: add pcs_inband_caps() method")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Link: https://patch.msgid.link/20260817213009.13924-1-ansuelsmth@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
52ffb39e71
commit
f2849b1fd0
@@ -964,7 +964,7 @@ static unsigned int phylink_inband_caps(struct phylink *pl,
|
||||
return 0;
|
||||
|
||||
pcs = pl->mac_ops->mac_select_pcs(pl->config, interface);
|
||||
if (!pcs)
|
||||
if (IS_ERR_OR_NULL(pcs))
|
||||
return 0;
|
||||
|
||||
return phylink_pcs_inband_caps(pcs, interface);
|
||||
|
||||
Reference in New Issue
Block a user