* [PATCH] net: ethernet: ti: cpsw_ale: Fix access to un-initialized memory
@ 2021-11-08 21:28 Christophe JAILLET
2021-11-10 14:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2021-11-08 21:28 UTC (permalink / raw)
To: grygorii.strashko, davem, kuba, shenyang39, vigneshr
Cc: linux-omap, netdev, linux-kernel, kernel-janitors,
Christophe JAILLET
It is spurious to allocate a bitmap without initializing it.
So, better safe than sorry, initialize it to 0 at least to have some known
values.
While at it, switch to the devm_bitmap_ API which is less verbose.
Fixes: 4b41d3436796 ("net: ethernet: ti: cpsw: allow untagged traffic on host port")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Maybe this patch is useless, because of some _add_vlan _del_vlan stuff that
initialize things correctly before they are used, but it really looks
spurious to me.
IIUC, cpsw_rx_vlan_encap() (and the embedded cpsw_ale_get_vlan_p0_untag()
could test any bit in the un-initialized bitmap)
Just a guess, I've not tried to understand all the logic involved.
---
drivers/net/ethernet/ti/cpsw_ale.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/ti/cpsw_ale.c b/drivers/net/ethernet/ti/cpsw_ale.c
index 0c75e0576ee1..1ef0aaef5c61 100644
--- a/drivers/net/ethernet/ti/cpsw_ale.c
+++ b/drivers/net/ethernet/ti/cpsw_ale.c
@@ -1299,10 +1299,8 @@ struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params)
if (!ale)
return ERR_PTR(-ENOMEM);
- ale->p0_untag_vid_mask =
- devm_kmalloc_array(params->dev, BITS_TO_LONGS(VLAN_N_VID),
- sizeof(unsigned long),
- GFP_KERNEL);
+ ale->p0_untag_vid_mask = devm_bitmap_zalloc(params->dev, VLAN_N_VID,
+ GFP_KERNEL);
if (!ale->p0_untag_vid_mask)
return ERR_PTR(-ENOMEM);
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: ethernet: ti: cpsw_ale: Fix access to un-initialized memory
2021-11-08 21:28 [PATCH] net: ethernet: ti: cpsw_ale: Fix access to un-initialized memory Christophe JAILLET
@ 2021-11-10 14:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-11-10 14:40 UTC (permalink / raw)
To: Christophe JAILLET
Cc: grygorii.strashko, davem, kuba, shenyang39, vigneshr, linux-omap,
netdev, linux-kernel, kernel-janitors
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Mon, 8 Nov 2021 22:28:55 +0100 you wrote:
> It is spurious to allocate a bitmap without initializing it.
> So, better safe than sorry, initialize it to 0 at least to have some known
> values.
>
> While at it, switch to the devm_bitmap_ API which is less verbose.
>
> Fixes: 4b41d3436796 ("net: ethernet: ti: cpsw: allow untagged traffic on host port")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>
> [...]
Here is the summary with links:
- net: ethernet: ti: cpsw_ale: Fix access to un-initialized memory
https://git.kernel.org/netdev/net/c/7a166854b4e2
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] 2+ messages in thread
end of thread, other threads:[~2021-11-10 14:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-08 21:28 [PATCH] net: ethernet: ti: cpsw_ale: Fix access to un-initialized memory Christophe JAILLET
2021-11-10 14:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).