From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) by dpdk.org (Postfix) with ESMTP id A04958E98 for ; Mon, 19 Oct 2015 11:45:24 +0200 (CEST) Received: by lffz202 with SMTP id z202so23405605lff.3 for ; Mon, 19 Oct 2015 02:45:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2yxxid4hgC9/2C7cxKrywOqipJtrmNsy8iXbIuOLtuU=; b=JLZHB7+OefEbCl0a941zVZM06/BjYN6zEEPUpYAq9l2fqcZjU0fE5g6LQFkCC73CFe fxLT+DUN0Ds6G5E/EWElnRiEns9AHnVi2avoeLSEwgGs971H6xSBTGeizWmB58iz7O0n pn33vQnN5CZ3CpuVGDO8vHI7/EzM1sLWCEnYoaO0OYj2teMuEIQDiTkpeeo5gYP1U1G3 O5cUe4VRBdZcOQFePlEVJl0mQhI4jQZG9cBtz234YM4pfDV5Nyo7VrtWKTOfuxvm/z6V PtJ4rJlC3TkNIkmVl63k8WccXHvZQUUfx2ViEXfDX0L1IaoqpDfoYr9CKqCwosET90L7 K7wA== X-Gm-Message-State: ALoCoQkxgpyn76kOftMIuluv+dx7GxMdlMPRKAVsdyao6/Us2qXp+6ivE+/RDpHX99SIx9b/HqFw X-Received: by 10.180.211.243 with SMTP id nf19mr20128182wic.74.1445247924363; Mon, 19 Oct 2015 02:45:24 -0700 (PDT) Received: from localhost.localdomain (ows-185-21-195-233.eu-west-1.compute.outscale.com. [185.21.195.233]) by smtp.gmail.com with ESMTPSA id xt1sm39011197wjb.32.2015.10.19.02.45.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 02:45:23 -0700 (PDT) From: Jerome Jutteau To: dev@dpdk.org Date: Mon, 19 Oct 2015 11:44:28 +0200 Message-Id: <1445247869-713-4-git-send-email-jerome.jutteau@outscale.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1445247869-713-1-git-send-email-jerome.jutteau@outscale.com> References: <1445247869-713-1-git-send-email-jerome.jutteau@outscale.com> Subject: [dpdk-dev] [PATCH v2 3/4] vhost: protect user_get_vring_base from unknown devices X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2015 09:45:24 -0000 get_device return is not checked and may cause segfault when device is not found. This patch fix this. Signed-off-by: Jerome Jutteau --- lib/librte_vhost/vhost_user/virtio-net-user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c b/lib/librte_vhost/vhost_user/virtio-net-user.c index 4689927..e0bc2a4 100644 --- a/lib/librte_vhost/vhost_user/virtio-net-user.c +++ b/lib/librte_vhost/vhost_user/virtio-net-user.c @@ -276,6 +276,8 @@ user_get_vring_base(struct vhost_device_ctx ctx, { struct virtio_net *dev = get_device(ctx); + if (dev == NULL) + return -1; /* We have to stop the queue (virtio) if it is running. */ if (dev->flags & VIRTIO_DEV_RUNNING) notify_ops->destroy_device(dev); -- jerome