mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] net: microchip: sparx5: Fix potential NULL pointer dereference
@ 2025-02-12 14:18 Wentao Liang
  2025-02-12 16:21 ` Alexander Lobakin
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2025-02-12 14:18 UTC (permalink / raw)
  To: Steen.Hegelund, daniel.machon
  Cc: UNGLinuxDriver, andrew+netdev, davem, edumazet, kuba, pabeni,
	linux-arm-kernel, netdev, linux-kernel, Wentao Liang, stable

Check the return value of vcap_keyfields() in
vcap_debugfs_show_rule_keyset(). If vcap_keyfields()
returns NULL, skip the keyfield to prevent a NULL pointer
dereference when calling vcap_debugfs_show_rule_keyfield().

Fixes: 610c32b2ce66 ("net: microchip: vcap: Add vcap_get_rule")
Cc: stable@vger.kernel.org # 6.2+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/ethernet/microchip/vcap/vcap_api_debugfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/microchip/vcap/vcap_api_debugfs.c b/drivers/net/ethernet/microchip/vcap/vcap_api_debugfs.c
index 59bfbda29bb3..e9e2f7af9be3 100644
--- a/drivers/net/ethernet/microchip/vcap/vcap_api_debugfs.c
+++ b/drivers/net/ethernet/microchip/vcap/vcap_api_debugfs.c
@@ -202,6 +202,8 @@ static int vcap_debugfs_show_rule_keyset(struct vcap_rule_internal *ri,
 
 	list_for_each_entry(ckf, &ri->data.keyfields, ctrl.list) {
 		keyfield = vcap_keyfields(vctrl, admin->vtype, ri->data.keyset);
+		if (!keyfield)
+			continue;
 		vcap_debugfs_show_rule_keyfield(vctrl, out, ckf->ctrl.key,
 						keyfield, &ckf->data);
 	}
-- 
2.42.0.windows.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-12 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-12 14:18 [PATCH v2] net: microchip: sparx5: Fix potential NULL pointer dereference Wentao Liang
2025-02-12 16:21 ` Alexander Lobakin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®