Skip to contentSkip to conversation

tg3: Use slab_build_skb() when needed

PATCH Applied Kees Cook 3 participants 3 messages Aug 18, 2023 – Aug 22, 2023

Subsystems (3)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 tg3: Use slab_build_skb() when needed

The tg3 driver will use kmalloc() under some conditions. Check the frag_size and use slab_build_skb() when frag_size is 0. Silences the warning introduced by commit ce098da1497c ("skbuff: Introduce slab_build_skb()"):

	Use slab_build_skb() instead
	...
	tg3_poll_work+0x638/0xf90 [tg3]
Cc Siva Reddy Kallam <[email protected]>
Cc Prashant Sreedharan <[email protected]>
Cc Michael Chan <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Bagas Sanjaya <[email protected]>
---
 drivers/net/ethernet/broadcom/tg3.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/tg3.c +4 -1
index 5ef073a79ce9..cb2810f175cc 100644
@@ -6881,7 +6881,10 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
 
 			ri->data = NULL;
 
-			skb = build_skb(data, frag_size);
+			if (frag_size)
+				skb = build_skb(data, frag_size);
+			else
+				skb = slab_build_skb(data);
 			if (!skb) {
 				tg3_frag_free(frag_size != 0, data);
 				goto drop_it_no_recycle;
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 43 lines · Kees Cook

The tg3 driver will use kmalloc() under some conditions. Check the frag_size and use slab_build_skb() when frag_size is 0. Silences the warning introduced by commit ce098da1497c ("skbuff: Introduce slab_build_skb()"):

        Use slab_build_skb() instead
        ...
        tg3_poll_work+0x638/0xf90 [tg3]
Cc Siva Reddy Kallam <[email protected]>
Cc Prashant Sreedharan <[email protected]>
Cc Michael Chan <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Bagas Sanjaya <[email protected]>
---
 drivers/net/ethernet/broadcom/tg3.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/tg3.c +4 -2
index 5ef073a79ce9..cb2810f175cc 100644
@@ -6881,7 +6881,10 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
 
                        ri->data = NULL;
 
-                       skb = build_skb(data, frag_size);
+                       if (frag_size)
+                               skb = build_skb(data, frag_size);
+                       else
+                               skb = slab_build_skb(data);
                        if (!skb) {
                                tg3_frag_free(frag_size != 0, data);
                                goto drop_it_no_recycle;
--
Quoted 3 lines

2.34.1

Thanks. LGTM.

#2 lore raw
In reply to Kees Cook
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 18 Aug 2023 10:54:21 -0700 you wrote:

The tg3 driver will use kmalloc() under some conditions. Check the frag_size and use slab_build_skb() when frag_size is 0. Silences the warning introduced by commit ce098da1497c ("skbuff: Introduce slab_build_skb()"):

	Use slab_build_skb() instead
	...
	tg3_poll_work+0x638/0xf90 [tg3]

[...]

Here is the summary with links:
- tg3: Use slab_build_skb() when needed

    https://git.kernel.org/netdev/net/c/99b415fe8986

You are awesome, thank you!

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