linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info
@ 2025-06-25 11:27 Chintan Vankar
  2025-06-25 13:37 ` Siddharth Vadapalli
  0 siblings, 1 reply; 3+ messages in thread
From: Chintan Vankar @ 2025-06-25 11:27 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, rogerq, horms,
	mwalle, jacob.e.keller, jpanis
  Cc: s-vadapalli, danishanwar, netdev, linux-kernel, Chintan Vankar

While transitioning from netdev_alloc_ip_align to build_skb, memory for
skb_shared_info was not allocated. Fix this by including
sizeof(skb_shared_info) in the packet length during allocation.

Fixes: 8acacc40f733 ("net: ethernet: ti: am65-cpsw: Add minimal XDP support")
Signed-off-by: Chintan Vankar <c-vankar@ti.com>
---

This patch is based on the commit '9caca6ac0e26' of origin/main branch of
Linux-net repository.

 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index f20d1ff192ef..3905eec0b11e 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -857,6 +857,7 @@ static struct sk_buff *am65_cpsw_build_skb(void *page_addr,
 	struct sk_buff *skb;
 
 	len += AM65_CPSW_HEADROOM;
+	len += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
 
 	skb = build_skb(page_addr, len);
 	if (unlikely(!skb))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info
  2025-06-25 11:27 [PATCH net] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info Chintan Vankar
@ 2025-06-25 13:37 ` Siddharth Vadapalli
  2025-06-26  5:31   ` Chintan Vankar
  0 siblings, 1 reply; 3+ messages in thread
From: Siddharth Vadapalli @ 2025-06-25 13:37 UTC (permalink / raw)
  To: Chintan Vankar
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, rogerq, horms,
	mwalle, jacob.e.keller, jpanis, s-vadapalli, danishanwar, netdev,
	linux-kernel

On Wed, Jun 25, 2025 at 04:57:25PM +0530, Chintan Vankar wrote:

Hello Chintan,

> While transitioning from netdev_alloc_ip_align to build_skb, memory for

nitpick: Add parantheses when referring to functions:
netdev_alloc_ip_align()
build_skb()

> skb_shared_info was not allocated. Fix this by including

Enclose structures within double quotes and preferably refer to them
in the context of an "skb":

...memory for the "skb_shared_info" member of an "skb" was not allocated...

> sizeof(skb_shared_info) in the packet length during allocation.
> 
> Fixes: 8acacc40f733 ("net: ethernet: ti: am65-cpsw: Add minimal XDP support")

> Signed-off-by: Chintan Vankar <c-vankar@ti.com>
> ---
> 
> This patch is based on the commit '9caca6ac0e26' of origin/main branch of
> Linux-net repository.
> 
>  drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index f20d1ff192ef..3905eec0b11e 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -857,6 +857,7 @@ static struct sk_buff *am65_cpsw_build_skb(void *page_addr,
>  	struct sk_buff *skb;
>  
>  	len += AM65_CPSW_HEADROOM;
> +	len += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));

This could be added to the previous line itself:

	len += AM65_CPSW_HEADROOM + SKB_DATA_ALIGN(sizeof(struct skb_shared_info));

>  
>  	skb = build_skb(page_addr, len);
>  	if (unlikely(!skb))

Thank you for finding the bug and fixing it.

Regards,
Siddharth.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info
  2025-06-25 13:37 ` Siddharth Vadapalli
@ 2025-06-26  5:31   ` Chintan Vankar
  0 siblings, 0 replies; 3+ messages in thread
From: Chintan Vankar @ 2025-06-26  5:31 UTC (permalink / raw)
  To: Siddharth Vadapalli
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, rogerq, horms,
	mwalle, jacob.e.keller, jpanis, danishanwar, netdev, linux-kernel

Hello Siddharth,

On 25/06/25 19:07, Siddharth Vadapalli wrote:
> On Wed, Jun 25, 2025 at 04:57:25PM +0530, Chintan Vankar wrote:
> 
> Hello Chintan,
> 
>> While transitioning from netdev_alloc_ip_align to build_skb, memory for
> 
> nitpick: Add parantheses when referring to functions:
> netdev_alloc_ip_align()
> build_skb()
> 
>> skb_shared_info was not allocated. Fix this by including
> 
> Enclose structures within double quotes and preferably refer to them
> in the context of an "skb":
> 
> ...memory for the "skb_shared_info" member of an "skb" was not allocated...
> 
>> sizeof(skb_shared_info) in the packet length during allocation.
>>
>> Fixes: 8acacc40f733 ("net: ethernet: ti: am65-cpsw: Add minimal XDP support")
> 
>> Signed-off-by: Chintan Vankar <c-vankar@ti.com>
>> ---
>>
>> This patch is based on the commit '9caca6ac0e26' of origin/main branch of
>> Linux-net repository.
>>
>>   drivers/net/ethernet/ti/am65-cpsw-nuss.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
>> index f20d1ff192ef..3905eec0b11e 100644
>> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
>> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
>> @@ -857,6 +857,7 @@ static struct sk_buff *am65_cpsw_build_skb(void *page_addr,
>>   	struct sk_buff *skb;
>>   
>>   	len += AM65_CPSW_HEADROOM;
>> +	len += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> 
> This could be added to the previous line itself:
> 
> 	len += AM65_CPSW_HEADROOM + SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> 
>>   
>>   	skb = build_skb(page_addr, len);
>>   	if (unlikely(!skb))
> 
> Thank you for finding the bug and fixing it.
> 

Thank you for reviewing patch. I have posted v2 by addressing your
comments at:
https://lore.kernel.org/r/20250626051226.2418638-1-c-vankar@ti.com/

Regards,
Chintan.

> Regards,
> Siddharth.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-26  5:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25 11:27 [PATCH net] net: ethernet: ti: am65-cpsw-nuss: Fix skb size by accounting for skb_shared_info Chintan Vankar
2025-06-25 13:37 ` Siddharth Vadapalli
2025-06-26  5:31   ` Chintan Vankar

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).