Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp364720pxf; Thu, 11 Mar 2021 05:56:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzcNNF5iR8hm5YMnLnMa8h9plpd+Alnwu2lbk6Gbos/EbHkjlKv9fHOuOfoAmyW6+8XCZa X-Received: by 2002:a50:e1c4:: with SMTP id m4mr8608657edl.182.1615471008238; Thu, 11 Mar 2021 05:56:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615471008; cv=none; d=google.com; s=arc-20160816; b=BZN7nf3RI2GnxbJtKoydPShEoDK1zjVlMrnPuDaALNOMSfjsqB98NDd9s66LS7Z4BD y0kAW8WbMoApz9xNMlLXgtUBJ80OVmS4bhFr7Vv0dQb1Jmtq+bCBqU7SlL3WkkdzbQHh svkaFr9cp7nrq4zkScK14A/cY8jXSBk22KqRj+AZ5AgpgqS3/9EjZNKc/MGb2Z3z0y6L 4lwLJOmsfO0AeJjroYdvX8vIdLJrF3rd2jhQnbbvqnjagVUjZCOTzpbPq45XRO3i2gwH JsD4q350krFvW3PqTu9r/p9Nhyq5XCF/7RWXtkMwKl/7Q5n/Rk4cxfAUnuc2kt/niAGK XlZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/SLu3G915tlJOckjof4gpfwcAaXUH6EnQojMQamSVhA=; b=p8qtI2CwKsZUD5r9yXH/N2x6HU2QysedcMpQPDd8AuC2MiGy4qFRtoKod2ZAvU4f/W cBh/VUASzXlDiGzoYeGdMj0cD27hkBaWS067Bb/G+muQWI5D8xugKyyKUDu+Cvdnxe33 jlJzxT0L+PmVBvu3d/KuWEOb7pdQJPcjoEtwvPhXey2Y0vyXIUEGv4DM4GRnKsK3jU9M 13sjcdcLA22inw0VQrOTgW9q0Xk8xZ17BR4JZvD9saPFsO7UZ3DcaItIie175CsFjtBV 8u980GkjVzoTTk3yiAhq1C4bX2fLpTJV0Q1ItwCHN7kEgE+IkoJNsOOyQB5c3leVGUQ5 SaYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aZSI5Gy4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si1694998edy.508.2021.03.11.05.56.25; Thu, 11 Mar 2021 05:56:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aZSI5Gy4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233844AbhCKNx1 (ORCPT + 99 others); Thu, 11 Mar 2021 08:53:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34447 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233812AbhCKNxO (ORCPT ); Thu, 11 Mar 2021 08:53:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615470793; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/SLu3G915tlJOckjof4gpfwcAaXUH6EnQojMQamSVhA=; b=aZSI5Gy49Y8nSBSET6/xsYyfhlhi0LGq+LyfoALSHHpts5+EMBCBAOaWhrbZKQG/Iyc6WG l6gO5OjkZpln531fglUWQujsqVOMl6xhR0b1iTqJkG0zRK0OJyoj6jvdgIVKcDyttUjgrN fIYdsBUyfExRKlO454n5VIWCl/1wY/g= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-2UF2uV0rPn6GuFfzEiwXzw-1; Thu, 11 Mar 2021 08:53:09 -0500 X-MC-Unique: 2UF2uV0rPn6GuFfzEiwXzw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EAE518030DB; Thu, 11 Mar 2021 13:53:07 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-113-146.ams2.redhat.com [10.36.113.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D923196E3; Thu, 11 Mar 2021 13:53:06 +0000 (UTC) From: Stefano Garzarella To: virtualization@lists.linux-foundation.org Cc: Jason Wang , netdev@vger.kernel.org, Zhu Lingshan , "Michael S. Tsirkin" , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH 2/2] vhost-vdpa: set v->config_ctx to NULL if eventfd_ctx_fdget() fails Date: Thu, 11 Mar 2021 14:52:57 +0100 Message-Id: <20210311135257.109460-3-sgarzare@redhat.com> In-Reply-To: <20210311135257.109460-1-sgarzare@redhat.com> References: <20210311135257.109460-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In vhost_vdpa_set_config_call() if eventfd_ctx_fdget() fails the 'v->config_ctx' contains an error instead of a valid pointer. Since we consider 'v->config_ctx' valid if it is not NULL, we should set it to NULL in this case to avoid to use an invalid pointer in other functions such as vhost_vdpa_config_put(). Fixes: 776f395004d8 ("vhost_vdpa: Support config interrupt in vdpa") Cc: lingshan.zhu@intel.com Cc: stable@vger.kernel.org Signed-off-by: Stefano Garzarella --- drivers/vhost/vdpa.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 00796e4ecfdf..f9ecdce5468a 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -331,8 +331,12 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp) if (!IS_ERR_OR_NULL(ctx)) eventfd_ctx_put(ctx); - if (IS_ERR(v->config_ctx)) - return PTR_ERR(v->config_ctx); + if (IS_ERR(v->config_ctx)) { + long ret = PTR_ERR(v->config_ctx); + + v->config_ctx = NULL; + return ret; + } v->vdpa->config->set_config_cb(v->vdpa, &cb); -- 2.29.2