Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1921923pxa; Thu, 6 Aug 2020 20:55:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD0QzSw4ufsdO92NbsIN6z72k/So5y5+MqN2mlMvcYT4qnuK7CexOy5mRIwQDvhvk+yZ87 X-Received: by 2002:a50:d1c2:: with SMTP id i2mr6808743edg.60.1596772548256; Thu, 06 Aug 2020 20:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596772548; cv=none; d=google.com; s=arc-20160816; b=bnMX1qvCIeA9Gtf1KT8HdpRkYZKIBQcQKaOs0Epc8Vpcm8n9ZiGVShj654he8sbz08 Iz/geoak138s4eAMST+MPxiHdNw3a0cYAoIWAfvLtZWyYKfDxbjQP3Djy6UmKWNtH4pM 2nDMfpbOR4rQ0yf7DxiUFM+fGmk3ElD9dS3+inE+XloASeAMuo6tkFHbIgsSqffB/370 AVYggo/kYj+pds/3DOvIU2eN+UhjOuh6rdcMZMwNDr6MaPcaxbzYfUzcLxwI8MzNXGKY boRMAROCkdCUOCUcGa6Is9wreTV62UNBPcQsac5riPrGuDGHrSRkRv9lSnN4/c0N5Fe0 +cvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=6DD+5YaxG5kafQGDO3acMANf5Iwxl41vTIRFwMojQUI=; b=i3qVH9Lyd/fXEBjPDs0X1dvxJ4n72kmoYBzIdxuD10FgrHZaCIA+1ETE8UVNg44D3N kD7SwWCuXGhjGyg2eTTWxJoSlJ3MIdl/fSqHPfFtCxiArkpjSgWmM6xEVqvAFYYYdOJq 4FE6HVfIZ37UEzaukEV2V6r01GCH9yyAiu93kTDF2MhsVbCAx3KIUVSkPgFhVP7iYa/0 yrSNcAoDw25vY1SlHEJm/14AePAsnMWz2Igt/5f48FtoMHFP9xqDY830ygmf70VCtVTL puId1smBNjALbMcHmr9vYX0hp+XYKIzy51UesaQH/haifSOGMM6hyB3t1tlbxM8/xSZJ 6KZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XR+z0pyz; 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 o9si4501705edw.550.2020.08.06.20.55.25; Thu, 06 Aug 2020 20:55:48 -0700 (PDT) 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=XR+z0pyz; 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 S1726155AbgHGDyZ (ORCPT + 99 others); Thu, 6 Aug 2020 23:54:25 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:58002 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726038AbgHGDyZ (ORCPT ); Thu, 6 Aug 2020 23:54:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596772464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6DD+5YaxG5kafQGDO3acMANf5Iwxl41vTIRFwMojQUI=; b=XR+z0pyzpmpdHRxx94xpq0EWDwkym32D13XJRvXmdRbcnbgqr5yg0txVCbYNDq7tQn+Y8c nJ915aTP4VpGoj2MDzE6wHntpdRU1HhgG37448MDza8tDLOyYp/FoMFk2dNXZT/r8tti61 DXm9UgtChaup/vVj+71sIwfdd0am34c= 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-484-Q7A8Z20-NoSg2T-18Pwq2Q-1; Thu, 06 Aug 2020 23:54:22 -0400 X-MC-Unique: Q7A8Z20-NoSg2T-18Pwq2Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A71F80046C; Fri, 7 Aug 2020 03:54:21 +0000 (UTC) Received: from [10.72.13.215] (ovpn-13-215.pek2.redhat.com [10.72.13.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5711D5F9DB; Fri, 7 Aug 2020 03:54:16 +0000 (UTC) Subject: Re: [PATCH] vdpa/mlx5: Fix uninitialised variable in core/mr.c To: Alex Dewar , "Michael S. Tsirkin" , Parav Pandit , Eli Cohen , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20200806185625.67344-1-alex.dewar@gmx.co.uk> From: Jason Wang Message-ID: <307a57f1-7038-f042-a786-bee636509a7b@redhat.com> Date: Fri, 7 Aug 2020 11:54:14 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200806185625.67344-1-alex.dewar@gmx.co.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/8/7 上午2:56, Alex Dewar wrote: > If the kernel is unable to allocate memory for the variable dmr then > err will be returned without being set. Set err to -ENOMEM in this > case. > > Fixes: 94abbccdf291 ("vdpa/mlx5: Add shared memory registration code") > Addresses-Coverity: ("Uninitialized variables") > Signed-off-by: Alex Dewar Acked-by: Jason Wang > --- > drivers/vdpa/mlx5/core/mr.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c > index f5dec0274133..ef1c550f8266 100644 > --- a/drivers/vdpa/mlx5/core/mr.c > +++ b/drivers/vdpa/mlx5/core/mr.c > @@ -319,8 +319,10 @@ static int add_direct_chain(struct mlx5_vdpa_dev *mvdev, u64 start, u64 size, u8 > while (size) { > sz = (u32)min_t(u64, MAX_KLM_SIZE, size); > dmr = kzalloc(sizeof(*dmr), GFP_KERNEL); > - if (!dmr) > + if (!dmr) { > + err = -ENOMEM; > goto err_alloc; > + } > > dmr->start = st; > dmr->end = st + sz; > -- > 2.28.0 >