* [PATCH] net: microchip: sparx5: Fix potential NULL pointer dereference in debugfs
@ 2025-02-12 9:18 Wentao Liang
2025-02-12 13:49 ` Andrew Lunn
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2025-02-12 9: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
In vcap_debugfs_show_rule_keyset(), the function vcap_keyfields()
returns a NULL pointer upon allocation failure. This can lead to
a NULL pointer dereference in vcap_debugfs_show_rule_keyfield().
To prevent this, add a check for a NULL return value from
vcap_keyfields() and continue the loop if it is NULL.
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* Re: [PATCH] net: microchip: sparx5: Fix potential NULL pointer dereference in debugfs
2025-02-12 9:18 [PATCH] net: microchip: sparx5: Fix potential NULL pointer dereference in debugfs Wentao Liang
@ 2025-02-12 13:49 ` Andrew Lunn
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2025-02-12 13:49 UTC (permalink / raw)
To: Wentao Liang
Cc: Steen.Hegelund, daniel.machon, UNGLinuxDriver, andrew+netdev,
davem, edumazet, kuba, pabeni, linux-arm-kernel, netdev,
linux-kernel, stable
On Wed, Feb 12, 2025 at 05:18:46PM +0800, Wentao Liang wrote:
> In vcap_debugfs_show_rule_keyset(), the function vcap_keyfields()
> returns a NULL pointer upon allocation failure.
/* Return the list of keyfields for the keyset */
const struct vcap_field *vcap_keyfields(struct vcap_control *vctrl,
enum vcap_type vt,
enum vcap_keyfield_set keyset)
{
/* Check that the keyset exists in the vcap keyset list */
if (keyset >= vctrl->vcaps[vt].keyfield_set_size)
return NULL;
return vctrl->vcaps[vt].keyfield_set_map[keyset];
}
I don't see any allocations here which can fail. I do agree it can
return NULL thought. So you code change looks correct, but you commit
message is broken.
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-12 13:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-12 9:18 [PATCH] net: microchip: sparx5: Fix potential NULL pointer dereference in debugfs Wentao Liang
2025-02-12 13:49 ` Andrew Lunn
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®