Skip to contentSkip to conversation

net: cpsw: Properly initialise struct page_pool_params

PATCH Applied Toke Høiland-Jørgensen 4 participants 6 messages Jan 24, 2022 – Jan 25, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: cpsw: Properly initialise struct page_pool_params

The cpsw driver didn't properly initialise the struct page_pool_params before calling page_pool_create(), which leads to crashes after the struct has been expanded with new parameters.

The second Fixes tag below is where the buggy code was introduced, but because the code was moved around this patch will only apply on top of the commit in the first Fixes tag.

Fixes c5013ac1dd0e ("net: ethernet: ti: cpsw: move set of common functions in cpsw_priv")
Fixes 9ed4050c0d75 ("net: ethernet: ti: cpsw: add XDP support")
---
 drivers/net/ethernet/ti/cpsw_priv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/cpsw_priv.c +1 -1
index ba220593e6db..8f6817f346ba 100644
@@ -1146,7 +1146,7 @@ int cpsw_fill_rx_channels(struct cpsw_priv *priv)
 static struct page_pool *cpsw_create_page_pool(struct cpsw_common *cpsw,
 					       int size)
 {
-	struct page_pool_params pp_params;
+	struct page_pool_params pp_params = {};
 	struct page_pool *pool;
 
 	pp_params.order = 0;
Signature · 1 line
2.34.1
#1 lore raw

Hi Toke,

Thanks for looking into this. I'll this patch this evening when I have access to hardware.

Colin Foster

Quoted 32 lines · Toke Høiland-Jørgensen

The cpsw driver didn't properly initialise the struct page_pool_params before calling page_pool_create(), which leads to crashes after the struct has been expanded with new parameters.

The second Fixes tag below is where the buggy code was introduced, but because the code was moved around this patch will only apply on top of the commit in the first Fixes tag.

Fixes c5013ac1dd0e ("net: ethernet: ti: cpsw: move set of common functions in cpsw_priv")
Fixes 9ed4050c0d75 ("net: ethernet: ti: cpsw: add XDP support")
---
 drivers/net/ethernet/ti/cpsw_priv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/cpsw_priv.c +1 -1
index ba220593e6db..8f6817f346ba 100644
@@ -1146,7 +1146,7 @@ int cpsw_fill_rx_channels(struct cpsw_priv *priv)
 static struct page_pool *cpsw_create_page_pool(struct cpsw_common *cpsw,
 					       int size)
 {
-	struct page_pool_params pp_params;
+	struct page_pool_params pp_params = {};
 	struct page_pool *pool;
 
 	pp_params.order = 0;
Signature · 1 line
2.34.1
Tested-by on v1 1/1
#2 lore raw
In reply to Toke Høiland-Jørgensen
Quoted 32 lines · Toke Høiland-Jørgensen

The cpsw driver didn't properly initialise the struct page_pool_params before calling page_pool_create(), which leads to crashes after the struct has been expanded with new parameters.

The second Fixes tag below is where the buggy code was introduced, but because the code was moved around this patch will only apply on top of the commit in the first Fixes tag.

Fixes c5013ac1dd0e ("net: ethernet: ti: cpsw: move set of common functions in cpsw_priv")
Fixes 9ed4050c0d75 ("net: ethernet: ti: cpsw: add XDP support")
---
 drivers/net/ethernet/ti/cpsw_priv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/cpsw_priv.c +1 -1
index ba220593e6db..8f6817f346ba 100644
@@ -1146,7 +1146,7 @@ int cpsw_fill_rx_channels(struct cpsw_priv *priv)
 static struct page_pool *cpsw_create_page_pool(struct cpsw_common *cpsw,
 					       int size)
 {
-	struct page_pool_params pp_params;
+	struct page_pool_params pp_params = {};
 	struct page_pool *pool;
 
 	pp_params.order = 0;
Signature · 1 line
2.34.1

Works for me. Thanks Toke! Hopefully my tested by tag addition is done correctly:

#3 lore raw
Quoted 37 lines · Colin Foster
Quoted 32 lines · Toke Høiland-Jørgensen

The cpsw driver didn't properly initialise the struct page_pool_params before calling page_pool_create(), which leads to crashes after the struct has been expanded with new parameters.

The second Fixes tag below is where the buggy code was introduced, but because the code was moved around this patch will only apply on top of the commit in the first Fixes tag.

Fixes c5013ac1dd0e ("net: ethernet: ti: cpsw: move set of common functions in cpsw_priv")
Fixes 9ed4050c0d75 ("net: ethernet: ti: cpsw: add XDP support")
---
 drivers/net/ethernet/ti/cpsw_priv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ti/cpsw_priv.c +1 -1
index ba220593e6db..8f6817f346ba 100644
@@ -1146,7 +1146,7 @@ int cpsw_fill_rx_channels(struct cpsw_priv *priv)
 static struct page_pool *cpsw_create_page_pool(struct cpsw_common *cpsw,
 					       int size)
 {
-	struct page_pool_params pp_params;
+	struct page_pool_params pp_params = {};
 	struct page_pool *pool;
 
 	pp_params.order = 0;
Signature · 1 line
2.34.1

Works for me. Thanks Toke! Hopefully my tested by tag addition is done correctly:

Quoted 1 line

You're welcome! Tag looks good, thanks for testing :)

-Toke

Acked-by on v1 1/1
#4 lore raw
In reply to Toke Høiland-Jørgensen
Quoted 8 lines · Toke Høiland-Jørgensen

The cpsw driver didn't properly initialise the struct page_pool_params before calling page_pool_create(), which leads to crashes after the struct has been expanded with new parameters.

The second Fixes tag below is where the buggy code was introduced, but because the code was moved around this patch will only apply on top of the commit in the first Fixes tag.

Quoted 5 lines
Fixes c5013ac1dd0e ("net: ethernet: ti: cpsw: move set of common functions in cpsw_priv")
Fixes 9ed4050c0d75 ("net: ethernet: ti: cpsw: add XDP support")

---

#5 lore raw
In reply to Toke Høiland-Jørgensen
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:

Quoted 9 lines · On Mon, 24 Jan 2022 15:35:29 +0100 you wrote:

The cpsw driver didn't properly initialise the struct page_pool_params before calling page_pool_create(), which leads to crashes after the struct has been expanded with new parameters.

The second Fixes tag below is where the buggy code was introduced, but because the code was moved around this patch will only apply on top of the commit in the first Fixes tag.

[...]

Here is the summary with links:
- [net] net: cpsw: Properly initialise struct page_pool_params

    https://git.kernel.org/netdev/net/c/c63003e3d997

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html