All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio_net: fix the potential NULL pointer in xmit_skb()
@ 2014-02-14  4:00 Zhi Yong Wu
  2014-02-14  5:12 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Zhi Yong Wu @ 2014-02-14  4:00 UTC (permalink / raw)
  To: netdev; +Cc: Zhi Yong Wu

The pointer hdr isn't assigned before hdr->mhdr and hdr->hdr
are used, so it could be one invalid pointer.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 drivers/net/virtio_net.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index d75f8ed..bf6397f 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -807,9 +807,9 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
 
 	pr_debug("%s: xmit %p %pM\n", vi->dev->name, skb, dest);
 	if (vi->mergeable_rx_bufs)
-		hdr_len = sizeof hdr->mhdr;
+		hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf);
 	else
-		hdr_len = sizeof hdr->hdr;
+		hdr_len = sizeof(struct virtio_net_hdr);
 
 	can_push = vi->any_header_sg &&
 		!((unsigned long)skb->data & (__alignof__(*hdr) - 1)) &&
-- 
1.8.4.2

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

* Re: [PATCH] virtio_net: fix the potential NULL pointer in xmit_skb()
  2014-02-14  4:00 [PATCH] virtio_net: fix the potential NULL pointer in xmit_skb() Zhi Yong Wu
@ 2014-02-14  5:12 ` David Miller
  2014-02-14  5:25   ` Zhi Yong Wu
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2014-02-14  5:12 UTC (permalink / raw)
  To: wuzhy; +Cc: netdev

From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Date: Fri, 14 Feb 2014 12:00:08 +0800

> The pointer hdr isn't assigned before hdr->mhdr and hdr->hdr
> are used, so it could be one invalid pointer.
> 
> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

sizeof(x) does not evaluate any dereferences made by 'x'

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

* Re: [PATCH] virtio_net: fix the potential NULL pointer in xmit_skb()
  2014-02-14  5:12 ` David Miller
@ 2014-02-14  5:25   ` Zhi Yong Wu
  0 siblings, 0 replies; 3+ messages in thread
From: Zhi Yong Wu @ 2014-02-14  5:25 UTC (permalink / raw)
  To: David Miller; +Cc: Zhi Yong Wu, Linux Netdev List

On Fri, Feb 14, 2014 at 1:12 PM, David Miller <davem@davemloft.net> wrote:
> From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
> Date: Fri, 14 Feb 2014 12:00:08 +0800
>
>> The pointer hdr isn't assigned before hdr->mhdr and hdr->hdr
>> are used, so it could be one invalid pointer.
>>
>> Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
>
> sizeof(x) does not evaluate any dereferences made by 'x'
thanks for your explanation.
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Regards,

Zhi Yong Wu

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

end of thread, other threads:[~2014-02-14  5:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-14  4:00 [PATCH] virtio_net: fix the potential NULL pointer in xmit_skb() Zhi Yong Wu
2014-02-14  5:12 ` David Miller
2014-02-14  5:25   ` Zhi Yong Wu

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.