Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1914783pxa; Thu, 6 Aug 2020 20:38:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysHf19QA9fTQAlok+oA1BvOkawSUqE4AGWLGVd8agP2xSV/IQgW9jmt96rMyVGWrOm7fKx X-Received: by 2002:aa7:c30b:: with SMTP id l11mr6919481edq.253.1596771532950; Thu, 06 Aug 2020 20:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596771532; cv=none; d=google.com; s=arc-20160816; b=n4EUayoq8ftky2bRDgwT1PQEcUVTeCvL5DuYRHC5sXEBkR6ozfSIqW+j2Z7QTACXEw gLgNfAQSlj+Xims4ILMjQ0hth/RescST5xGIrsw0sLnmKwicN98Z3meazBgQshqlnRfy 2ymNOQfkhhwmh8MVqpYEapnx8cT+y62Gy4lQjUm59PmgRPUjRuB1jAVZzLQ80TcKD3/0 HjTMDL3z1+vjuMnq1P/T92ganb2H5fTYA965RmeGOm0JX9efRSl7O1q6LsPqk/+Mbofx y6L1z2Mrpj/8laTTZRs+rrAbewodbH6NyETicB/tlIiqMRVS7Vo3AVM/JS6ZeZiMFKgg 7P1A== 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=BJmVwYKYH9OYU5nifyyFiwbUHIzwYs48cjjAmAqd4Ak=; b=EuG9B6YJgR6IIY7syndP9/pW9A0pjB7/zaOuuH7ptaQzkIMT4Ws0LNKC7JAWCxkxAn Fmwpggo1Yt1/Un3kXifMAmSPdEjrD+kGdB6BsHf9mQypx4fBeNTdRWWz27SqOp8h52fj 0mqXXcy6rbqoxUlonJctV7jwrUWqixxorYZsy8+70KazbLczNA54sAHspQYw82Q6yuBA ai7lyJD1abar9//cIqtaE7nBgiTBYOrHdnVxlZT3nytslfYnMyK7Qjbia4yUlZE1gCQk OsHsCrBS5vqa4Xo1yYZAeXwBP7aJeVIECzlkDdZdSB7vaL7VD+89n2SzUUN2uzrNbN2q z2VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="D/WafUrZ"; 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 o9si4381078edq.412.2020.08.06.20.38.29; Thu, 06 Aug 2020 20:38:52 -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="D/WafUrZ"; 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 S1726130AbgHGDhi (ORCPT + 99 others); Thu, 6 Aug 2020 23:37:38 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:52834 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726038AbgHGDhh (ORCPT ); Thu, 6 Aug 2020 23:37:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596771455; 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=BJmVwYKYH9OYU5nifyyFiwbUHIzwYs48cjjAmAqd4Ak=; b=D/WafUrZDE/FeyZO6hjOx9jIvJ0ZOr1KQ5E2w3Y9cdp9BCE6+tZ/t5XSH5UYwLq30lBNtT uykituP9V5VTZFvthnp/AaXbikgTpAWJGmiIOEHmxjrdZUO3BLHRF1R3x8s8jMShV3JOZw PjyOynnxXnbAGTuL/RX2gCROooRGL4w= 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-75-3YYVa6ZLPMigqQOdgYyetg-1; Thu, 06 Aug 2020 23:37:34 -0400 X-MC-Unique: 3YYVa6ZLPMigqQOdgYyetg-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 BA2B98017FB; Fri, 7 Aug 2020 03:37:32 +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 F27FC2DE8C; Fri, 7 Aug 2020 03:37:26 +0000 (UTC) Subject: Re: [PATCH] vdpa/mlx5: Fix erroneous null pointer checks To: Alex Dewar , "Michael S. Tsirkin" , Parav Pandit , Eli Cohen , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <20200806191849.82189-1-alex.dewar90@gmail.com> From: Jason Wang Message-ID: Date: Fri, 7 Aug 2020 11:37:25 +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: <20200806191849.82189-1-alex.dewar90@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/8/7 上午3:18, Alex Dewar wrote: > In alloc_inout() in net/mlx5_vnet.c, there are a few places where memory > is allocated to *in and *out, but only the values of in and out are > null-checked (i.e. there is a missing dereference). Fix this. > > Addresses-Coverity: ("CID 1496603: (REVERSE_INULL)") > Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices") > Signed-off-by: Alex Dewar Acked-by: Jason Wang > --- > drivers/vdpa/mlx5/net/mlx5_vnet.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > index 3ec44a4f0e45..bcb6600c2839 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -867,7 +867,7 @@ static void alloc_inout(struct mlx5_vdpa_net *ndev, int cmd, void **in, int *inl > *outlen = MLX5_ST_SZ_BYTES(qp_2rst_out); > *in = kzalloc(*inlen, GFP_KERNEL); > *out = kzalloc(*outlen, GFP_KERNEL); > - if (!in || !out) > + if (!*in || !*out) > goto outerr; > > MLX5_SET(qp_2rst_in, *in, opcode, cmd); > @@ -879,7 +879,7 @@ static void alloc_inout(struct mlx5_vdpa_net *ndev, int cmd, void **in, int *inl > *outlen = MLX5_ST_SZ_BYTES(rst2init_qp_out); > *in = kzalloc(*inlen, GFP_KERNEL); > *out = kzalloc(MLX5_ST_SZ_BYTES(rst2init_qp_out), GFP_KERNEL); > - if (!in || !out) > + if (!*in || !*out) > goto outerr; > > MLX5_SET(rst2init_qp_in, *in, opcode, cmd); > @@ -896,7 +896,7 @@ static void alloc_inout(struct mlx5_vdpa_net *ndev, int cmd, void **in, int *inl > *outlen = MLX5_ST_SZ_BYTES(init2rtr_qp_out); > *in = kzalloc(*inlen, GFP_KERNEL); > *out = kzalloc(MLX5_ST_SZ_BYTES(init2rtr_qp_out), GFP_KERNEL); > - if (!in || !out) > + if (!*in || !*out) > goto outerr; > > MLX5_SET(init2rtr_qp_in, *in, opcode, cmd); > @@ -914,7 +914,7 @@ static void alloc_inout(struct mlx5_vdpa_net *ndev, int cmd, void **in, int *inl > *outlen = MLX5_ST_SZ_BYTES(rtr2rts_qp_out); > *in = kzalloc(*inlen, GFP_KERNEL); > *out = kzalloc(MLX5_ST_SZ_BYTES(rtr2rts_qp_out), GFP_KERNEL); > - if (!in || !out) > + if (!*in || !*out) > goto outerr; > > MLX5_SET(rtr2rts_qp_in, *in, opcode, cmd);