drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++++ 1 file changed, 4 insertions(+)
As the possible failure of the allocation, kzalloc() may return NULL
pointer.
Therefore, it should be better to check the 'sgi' in order to prevent
the dereference of NULL pointer.
Fixes: 23ae3a7877718 ("net: dsa: felix: add stream gate settings for psfpq").
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
index 33f0ceae381d..2875b5250856 100644
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -1940,6 +1940,10 @@ static int vsc9959_psfp_filter_add(struct ocelot *ocelot, int port,
case FLOW_ACTION_GATE:
size = struct_size(sgi, entries, a->gate.num_entries);
sgi = kzalloc(size, GFP_KERNEL);
+ if (!sgi) {
+ ret = -ENOMEM;
+ goto err;
+ }
vsc9959_psfp_parse_gate(a, sgi);
ret = vsc9959_psfp_sgi_table_add(ocelot, sgi);
if (ret) {
--
2.17.1
Hello,
On Tue, 2022-03-29 at 08:12 +0000, Zheng Yongjun wrote:
> As the possible failure of the allocation, kzalloc() may return NULL
> pointer.
> Therefore, it should be better to check the 'sgi' in order to prevent
> the dereference of NULL pointer.
>
> Fixes: 23ae3a7877718 ("net: dsa: felix: add stream gate settings for psfpq").
It looks like the fixes tag has been corrupted (trailing 'q'). Would
you mind posting a v2 with that fixed ?
Thanks,
Paolo
Thanks for point out my mistake :)
-----邮件原件-----
发件人: Paolo Abeni [mailto:pabeni@redhat.com]
发送时间: 2022年3月29日 17:00
收件人: zhengyongjun <zhengyongjun3@huawei.com>; andrew@lunn.ch; vivien.didelot@gmail.com; f.fainelli@gmail.com; davem@davemloft.net; kuba@kernel.org; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
抄送: vladimir.oltean@nxp.com; claudiu.manoil@nxp.com; alexandre.belloni@bootlin.com; UNGLinuxDriver@microchip.com
主题: Re: [PATCH] net: dsa: felix: fix possible NULL pointer dereference
Hello,
On Tue, 2022-03-29 at 08:12 +0000, Zheng Yongjun wrote:
> As the possible failure of the allocation, kzalloc() may return NULL
> pointer.
> Therefore, it should be better to check the 'sgi' in order to prevent
> the dereference of NULL pointer.
>
> Fixes: 23ae3a7877718 ("net: dsa: felix: add stream gate settings for psfpq").
It looks like the fixes tag has been corrupted (trailing 'q'). Would you mind posting a v2 with that fixed ?
Thanks,
Paolo
© 2016 - 2026 Red Hat, Inc.