Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1650974pxa; Thu, 6 Aug 2020 12:28:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+32BC7BfbR1lZWFhRwKKqbltITh39SLybjqcRrEbBtlQuxb+3lHliy48O74dRYoTTQuty X-Received: by 2002:a17:906:f290:: with SMTP id gu16mr5778619ejb.502.1596742094675; Thu, 06 Aug 2020 12:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596742094; cv=none; d=google.com; s=arc-20160816; b=dkhjp/bZr+mtE4kE3MGTIsD38gl1iGkR7KXge9UYTephpHfJ3lbjpFNJOLz4dypWV6 qj+gSARCdO/dRWS/qIWzpUVWuRScRbXD+mVlAzMUUmp8e/bOVx5xvnbU9ZRJ8dwrP2TU Q/Hyczo7NgahR8Wug8WoDRShcCTf/DHt/ThT0m4u+iPCSS0pb9xzus7CUfZu9++TI4Vf b/scR1FR7phwHQm7kjKGuwcoj9cR5bEL3zzPkIEtAk73f4dzHau4OauEEJ4HTPUfxSz0 6wadLNDapksso50fEmaLdzMJyt/BMDRd+7M/GL58gfok77ZcfpbGL8iqzDArrXfBHBNR c03g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=nBU/pM3MYlEmZitwD1KhBWl8EEKhumB4q1qsW3XKr34=; b=FfHtDHE7PO24qS5J+K0QAYNUx8eEJvrXvyyoWFHkj0YmkEUdM1mEHakD43XSoZdJvm PdXbH1gvrN96xBuQMm4WAm6I3YaIliZhGGpsxWCpEHqgySFCOURA93gjEhEwUmB/35yq SyiWvOm6VqXpi5F1l0m0naPBVVnxME5KgGvV31FdbpH2xchafCi7fyWOtGAySlfYZMcP HpkqwvjwSZo7G66W9lPC5PSJl/hebQ/y+l/9srFFiPAeyhb94HIDAGE1mRX+bYJpnU0g pJgUUFJrcXdUxD6WPpMyNyrKEBXBJjldoa4TNaAAoNYXmBmzHZnzG3sF2YVTLkhCM8e1 Ao3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DwDiI7JR; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h1si3688541edv.192.2020.08.06.12.27.51; Thu, 06 Aug 2020 12:28:14 -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=@gmail.com header.s=20161025 header.b=DwDiI7JR; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726209AbgHFTZJ (ORCPT + 99 others); Thu, 6 Aug 2020 15:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725272AbgHFTZI (ORCPT ); Thu, 6 Aug 2020 15:25:08 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1046C061574 for ; Thu, 6 Aug 2020 12:19:06 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id y3so45050444wrl.4 for ; Thu, 06 Aug 2020 12:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=nBU/pM3MYlEmZitwD1KhBWl8EEKhumB4q1qsW3XKr34=; b=DwDiI7JRoKfd2/50mvMUbKhYmterRGUW3oT7ZbKdfmD00qEpTgvlqq6Liqo6Xxq2Ac IDEOFJ9vfek3fTe4GivTbNOJSxdhPpmYXFlG57g17ii07PgbfsVHG/PdwRMVORw53WhR CTrupnia/072ruKaZKastIIW0MsEV7IeTagJyKabuBJpTF2SfOUA7lHgugcV47mvMl7o KN7OP25lO6CSsllz3c4NUUJNcoDAnhkK8ilWKZhHoDBgUSZX1tXrUddmHUzttCx9FhCU ySZGj/NdrmNx6vnPhU8CVcNRKqMPbudi25jZNGC/qzQZvjZQCx2aywWcIkn/XfHWm3jE 2khg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=nBU/pM3MYlEmZitwD1KhBWl8EEKhumB4q1qsW3XKr34=; b=trQUw2R8h80RQGahzE08MVDbnX6mcbBy9/D3lr8yLCLfKUYjQFDM8ddHUZIQs8PayV HdiTY40O5rhg8xLEFJWltmfjwUiHOLIXtMv/bz300M/3KPyamUB9yhOyzUI/6a+RD0s+ 6drSkScVMEaY8VYtih0G5EAcpzTXH2xYXE4N4Z7W8p1kJFszfFO6WgmZH51pA4Q1vWSK FJT3HETU06jUnLQgdbEe1ejYCkM6l15yI6c1xnj7wFp3IL4qHDlaPPQ+fyjLPbObMoYl PApDzY5Ahjeddy97QunCdlj4saxVJkztSjO98pfNL+GSgZwZzxNhoEI438PZsH5OUquG af4A== X-Gm-Message-State: AOAM531jRFkzBcdp/2UEwYX54+OBL5vDWTpjmkvt53h0TBNSHm5Ms+na kBqtC/1rxHn+Dz3GVpEqeW0= X-Received: by 2002:adf:9e8b:: with SMTP id a11mr8464291wrf.309.1596741545387; Thu, 06 Aug 2020 12:19:05 -0700 (PDT) Received: from localhost.localdomain (cpc83647-brig20-2-0-cust926.3-3.cable.virginm.net. [82.19.195.159]) by smtp.gmail.com with ESMTPSA id f15sm7172154wmj.39.2020.08.06.12.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2020 12:19:04 -0700 (PDT) From: Alex Dewar To: "Michael S. Tsirkin" , Jason Wang , Parav Pandit , Eli Cohen , Alex Dewar , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] vdpa/mlx5: Fix erroneous null pointer checks Date: Thu, 6 Aug 2020 20:18:39 +0100 Message-Id: <20200806191849.82189-1-alex.dewar90@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); -- 2.28.0