Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1008965pxf; Thu, 11 Mar 2021 22:45:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUSNkq2JPtMjplP82ayeYJzPxIZDw4R+a0iiuq7XdTBQaFcXnZDiif4lhLyVlVFTBVacbb X-Received: by 2002:a05:6402:549:: with SMTP id i9mr12721281edx.379.1615531521683; Thu, 11 Mar 2021 22:45:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615531521; cv=none; d=google.com; s=arc-20160816; b=Ds7WwFarD09WWhQadT8HjYcb+9Q3WV+plmqk6UTal4zXq3z7X/21TbDtkE8e+DubD5 vG8Pdhgci0XHgNPAWJWrZEn/xWyUJL0bRvO/uuhdhL4owrENWbfiX590cAn9RFtI1arS jqXkbDJxPlTwV+qNi+gkz7dBGF3VURUQroJx1bHlVUO1gSf0e4asmwJpH3z54T3TaS0Q dJDFMNAIYfeDJW1JI5/E73hbWyZ4xGGY9syHXxP48QOebfaEUCCHfkQyaYaikmCE7Bkq 1pkyxq53Zn9WCsDFIeOndnKvq+sMFP/Nn3R2DBiLU+K7S63b7hKPtedtCKK4eQSsEHRw u1hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=R+1V19JdRYahq0X3XulqGaxRbIWtSn54ETW3FVVrlmE=; b=Mpr60Bdf8CPzziyX38awOLymvkA8MUI8wm47V218ogFpZ4BdFOwJX7m+eWS2h53iIs 39/qrCzAq7MmogORTuY1SKrv0/vbcF778fmRDSgM8UjrfKV5XwyEHn5AcKM9LkZXcZFx 065ifp405jjLf4b/7u1RvguyjZi8ibHiUMWA4usPyaKICBsmCanPEg4oAQi6w3eIXun+ hA1l0lg85pXCznrQk7y/nuCwq3I7gTdTBzDAW3dsTdrrZMvBHmeeVzebETwmmUeqbmoG nUEU4fYzSaXwelfDewhxXbQEpSFx6WxLsb7luJsoyRUd9PxZNA/n56iuixXC8qeWw1Pu Ee7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FHrGcobM; 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 z1si3490090edx.401.2021.03.11.22.45.00; Thu, 11 Mar 2021 22:45:21 -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=FHrGcobM; 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 S231827AbhCLGev (ORCPT + 99 others); Fri, 12 Mar 2021 01:34:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43405 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231802AbhCLGe2 (ORCPT ); Fri, 12 Mar 2021 01:34:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615530867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R+1V19JdRYahq0X3XulqGaxRbIWtSn54ETW3FVVrlmE=; b=FHrGcobMh8UxhcyXShCldgtxlLw9uMqPDSQY8yDE55ij/34SX4m1ekOzfDp97qJV8+n6Pk AlXDQ5W/gjv2oOcfWE0YkNiXSzGVeokM00C3Biax/DvYE6jyH1kosLhv5/rCiVi944PgUH lopWkRVxE1VeqQ4qjIY0HadLSIv8/tA= 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-429-m9UsF-HzPbOe7woipQPy0g-1; Fri, 12 Mar 2021 01:34:21 -0500 X-MC-Unique: m9UsF-HzPbOe7woipQPy0g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C31C107ACCA; Fri, 12 Mar 2021 06:34:20 +0000 (UTC) Received: from wangxiaodeMacBook-Air.local (ovpn-13-168.pek2.redhat.com [10.72.13.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C04018A77; Fri, 12 Mar 2021 06:34:12 +0000 (UTC) Subject: Re: [PATCH 2/2] vhost-vdpa: set v->config_ctx to NULL if eventfd_ctx_fdget() fails To: Stefano Garzarella , virtualization@lists.linux-foundation.org Cc: netdev@vger.kernel.org, Zhu Lingshan , "Michael S. Tsirkin" , linux-kernel@vger.kernel.org, kvm@vger.kernel.org References: <20210311135257.109460-1-sgarzare@redhat.com> <20210311135257.109460-3-sgarzare@redhat.com> From: Jason Wang Message-ID: Date: Fri, 12 Mar 2021 14:34:07 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210311135257.109460-3-sgarzare@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/3/11 9:52 下午, Stefano Garzarella wrote: > 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 Acked-by: Jason Wang > --- > 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); >