From patchwork Fri Oct 16 09:08:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Jutteau X-Patchwork-Id: 7689 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 892F68E96; Fri, 16 Oct 2015 11:09:35 +0200 (CEST) Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by dpdk.org (Postfix) with ESMTP id 0FB4E8DAB for ; Fri, 16 Oct 2015 11:09:32 +0200 (CEST) Received: by wijp11 with SMTP id p11so649150wij.0 for ; Fri, 16 Oct 2015 02:09:32 -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=l8V1bcAucmoGOve3uYiMlTF65alCHwf8bQI4gK/fLVeXj+WsgBH1X0vuaU+LA78iS+ 0baJuDohIjaTFPHXgoYxTVG76RYRT2ttz26eY/J4HDLv7oWDoe5+5MKwS/jBfAt/qT1z FC9DzrAubU5W9gWSgc81Bo7yWs5ieE/ju4WH7oH6DG3/wPGqFKaINxQ6/wqbxvCwPDsK F9dDHr+b0soBdY2z1W6R+1dQdMDw5rU69eDn6SIn2ZhGK0LoMG1xnCrFU5Opbpio70XW PWVTm/58YvhwkjUF9La+rnuowFhbkgpAzC5PL9PI/nqrgX2nWAm+J4Mhg2xrJxAGDLor WnJQ== X-Gm-Message-State: ALoCoQmYawF5XApNRV/x5FCoYVNQ4f5/79xYQ/f8DogNmH7Y1gDkJ/MB2I/JxeA1i5lm9jjD/an9 X-Received: by 10.194.172.228 with SMTP id bf4mr15189445wjc.80.1444986571926; Fri, 16 Oct 2015 02:09:31 -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 ft2sm2409818wic.24.2015.10.16.02.09.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Oct 2015 02:09:31 -0700 (PDT) From: Jerome Jutteau To: dev@dpdk.org Date: Fri, 16 Oct 2015 11:08:50 +0200 Message-Id: <1444986530-20893-4-git-send-email-jerome.jutteau@outscale.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1444986530-20893-1-git-send-email-jerome.jutteau@outscale.com> References: <1444986530-20893-1-git-send-email-jerome.jutteau@outscale.com> Cc: changchun.ouyang@intel.com Subject: [dpdk-dev] [PATCH 3/3] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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);