* [PATCH] net: sparx5: switchdev: fix possible NULL pointer dereference
@ 2022-03-26 8:12 ` Zheng Yongjun
0 siblings, 0 replies; 4+ messages in thread
From: Zheng Yongjun @ 2022-03-26 8:12 UTC (permalink / raw)
To: davem, kuba, netdev, linux-arm-kernel, linux-kernel
Cc: lars.povlsen, Steen.Hegelund, UNGLinuxDriver
As the possible failure of the allocation, devm_kzalloc() may return NULL
pointer.
Therefore, it should be better to check the 'db' in order to prevent
the dereference of NULL pointer.
Fixes: 10615907e9b51 ("net: sparx5: switchdev: adding frame DMA functionality")
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
index 7436f62fa152..174ad95e746a 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
@@ -420,6 +420,8 @@ static int sparx5_fdma_tx_alloc(struct sparx5 *sparx5)
db_hw->dataptr = phys;
db_hw->status = 0;
db = devm_kzalloc(sparx5->dev, sizeof(*db), GFP_KERNEL);
+ if (!db)
+ return -ENOMEM;
db->cpu_addr = cpu_addr;
list_add_tail(&db->list, &tx->db_list);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] net: sparx5: switchdev: fix possible NULL pointer dereference
@ 2022-03-26 8:12 ` Zheng Yongjun
0 siblings, 0 replies; 4+ messages in thread
From: Zheng Yongjun @ 2022-03-26 8:12 UTC (permalink / raw)
To: davem, kuba, netdev, linux-arm-kernel, linux-kernel
Cc: lars.povlsen, Steen.Hegelund, UNGLinuxDriver
As the possible failure of the allocation, devm_kzalloc() may return NULL
pointer.
Therefore, it should be better to check the 'db' in order to prevent
the dereference of NULL pointer.
Fixes: 10615907e9b51 ("net: sparx5: switchdev: adding frame DMA functionality")
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
index 7436f62fa152..174ad95e746a 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
@@ -420,6 +420,8 @@ static int sparx5_fdma_tx_alloc(struct sparx5 *sparx5)
db_hw->dataptr = phys;
db_hw->status = 0;
db = devm_kzalloc(sparx5->dev, sizeof(*db), GFP_KERNEL);
+ if (!db)
+ return -ENOMEM;
db->cpu_addr = cpu_addr;
list_add_tail(&db->list, &tx->db_list);
}
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: sparx5: switchdev: fix possible NULL pointer dereference
2022-03-26 8:12 ` Zheng Yongjun
@ 2022-03-26 18:50 ` patchwork-bot+netdevbpf
-1 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-26 18:50 UTC (permalink / raw)
To: Zheng Yongjun
Cc: davem, kuba, netdev, linux-arm-kernel, linux-kernel,
lars.povlsen, Steen.Hegelund, UNGLinuxDriver
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Sat, 26 Mar 2022 08:12:39 +0000 you wrote:
> As the possible failure of the allocation, devm_kzalloc() may return NULL
> pointer.
> Therefore, it should be better to check the 'db' in order to prevent
> the dereference of NULL pointer.
>
> Fixes: 10615907e9b51 ("net: sparx5: switchdev: adding frame DMA functionality")
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
>
> [...]
Here is the summary with links:
- net: sparx5: switchdev: fix possible NULL pointer dereference
https://git.kernel.org/netdev/net/c/0906f3a3df07
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: sparx5: switchdev: fix possible NULL pointer dereference
@ 2022-03-26 18:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-26 18:50 UTC (permalink / raw)
To: Zheng Yongjun
Cc: davem, kuba, netdev, linux-arm-kernel, linux-kernel,
lars.povlsen, Steen.Hegelund, UNGLinuxDriver
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Sat, 26 Mar 2022 08:12:39 +0000 you wrote:
> As the possible failure of the allocation, devm_kzalloc() may return NULL
> pointer.
> Therefore, it should be better to check the 'db' in order to prevent
> the dereference of NULL pointer.
>
> Fixes: 10615907e9b51 ("net: sparx5: switchdev: adding frame DMA functionality")
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
>
> [...]
Here is the summary with links:
- net: sparx5: switchdev: fix possible NULL pointer dereference
https://git.kernel.org/netdev/net/c/0906f3a3df07
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-26 18:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-26 8:12 [PATCH] net: sparx5: switchdev: fix possible NULL pointer dereference Zheng Yongjun
2022-03-26 8:12 ` Zheng Yongjun
2022-03-26 18:50 ` patchwork-bot+netdevbpf
2022-03-26 18:50 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.