DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/virtio: fix null pointer dereference
@ 2016-07-05 11:42 Jianfeng Tan
  2016-07-05 12:14 ` Yuanhan Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Jianfeng Tan @ 2016-07-05 11:42 UTC (permalink / raw)
  To: dev; +Cc: yuanhan.liu, huawei.xie, michalx.k.jastrzebski, Jianfeng Tan

There is a logic bug in this code, that could lead to null pointer
dereference when cvq is NULL. Fix this problem by changing logic
_and_ to logic _or_.

   >> CID 127480:  Null pointer dereferences  (FORWARD_NULL)
   >> Dereferencing null pointer "cvq".
   	if (!cvq && !cvq->vq) {
            ...
        }

Coverity issue: 127480

Fixes: 01ad44fd374f ("net/virtio: split Rx/Tx queue")

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 480daa3..828afef 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -166,7 +166,7 @@ virtio_send_command(struct virtnet_ctl *cvq, struct virtio_pmd_ctrl *ctrl,
 
 	ctrl->status = status;
 
-	if (!cvq && !cvq->vq) {
+	if (!cvq || !cvq->vq) {
 		PMD_INIT_LOG(ERR, "Control queue is not supported.");
 		return -1;
 	}
-- 
2.1.4

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

* Re: [dpdk-dev] [PATCH] net/virtio: fix null pointer dereference
  2016-07-05 11:42 [dpdk-dev] [PATCH] net/virtio: fix null pointer dereference Jianfeng Tan
@ 2016-07-05 12:14 ` Yuanhan Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Yuanhan Liu @ 2016-07-05 12:14 UTC (permalink / raw)
  To: Jianfeng Tan; +Cc: dev, huawei.xie, michalx.k.jastrzebski

On Tue, Jul 05, 2016 at 11:42:59AM +0000, Jianfeng Tan wrote:
> There is a logic bug in this code, that could lead to null pointer
> dereference when cvq is NULL. Fix this problem by changing logic
> _and_ to logic _or_.
> 
>    >> CID 127480:  Null pointer dereferences  (FORWARD_NULL)
>    >> Dereferencing null pointer "cvq".
>    	if (!cvq && !cvq->vq) {
>             ...
>         }
> 
> Coverity issue: 127480
> 
> Fixes: 01ad44fd374f ("net/virtio: split Rx/Tx queue")
> 
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>

Applied to dpdk-next-virtio.

Thanks.

	--yliu

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

end of thread, other threads:[~2016-07-05 12:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05 11:42 [dpdk-dev] [PATCH] net/virtio: fix null pointer dereference Jianfeng Tan
2016-07-05 12:14 ` Yuanhan Liu

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