Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752320AbcLDGPJ (ORCPT ); Sun, 4 Dec 2016 01:15:09 -0500 Received: from mail.kernel.org ([198.145.29.136]:58928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750815AbcLDGPH (ORCPT ); Sun, 4 Dec 2016 01:15:07 -0500 Date: Sun, 4 Dec 2016 08:15:01 +0200 From: Leon Romanovsky To: Pan Bian Cc: Yishai Hadas , Doug Ledford , Sean Hefty , Hal Rosenstock , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Pan Bian Subject: Re: [PATCH 1/1] infiniband: hw: mlx4: fix improper return value Message-ID: <20161204061501.GG4497@leon.nu> References: <1480830544-5002-1-git-send-email-bianpan201603@163.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="V32M1hWVjliPHW+c" Content-Disposition: inline In-Reply-To: <1480830544-5002-1-git-send-email-bianpan201603@163.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2542 Lines: 71 --V32M1hWVjliPHW+c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sun, Dec 04, 2016 at 01:49:04PM +0800, Pan Bian wrote: > From: Pan Bian > > If uhw->inlen is non-zero, the value of variable err is 0 if the copy > succeeds. Then, if kzalloc() or kmalloc() returns a NULL pointer, it > will return 0 to the callers. As a result, the callers cannot detect the > errors. This patch fixes the bug, assigning "-ENOMEM" to err before > the NULL pointer checks. > > Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189031 > > Signed-off-by: Pan Bian > --- > drivers/infiniband/hw/mlx4/main.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c > index b597e82..f6c5158 100644 > --- a/drivers/infiniband/hw/mlx4/main.c > +++ b/drivers/infiniband/hw/mlx4/main.c > @@ -455,6 +455,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev, > sizeof(resp.response_length); > in_mad = kzalloc(sizeof *in_mad, GFP_KERNEL); > out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL); > + err = -ENOMEM; > if (!in_mad || !out_mad) > goto out; In such case, the err initialization at the beginning of mlx4_ib_query_device function is not necessary. Can you please remove it? Besides that, look good. Reviewed-by: Leon Romanovsky > > -- > 1.9.1 > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html --V32M1hWVjliPHW+c Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJYQ7RlAAoJEORje4g2clinbysQAINtYJh5d5AQ5WuzLwlmIe8L clfC1ff0WT9Rvh2Y9WRZdVeQMsaa7krVVG1IxOAVbrYPLksD4If3rR6rCrqjPiNo L6YfStgpeer5xygAw8fTVrtqnK6N9Djmu9y2ky1FNuMjKVIvdWg6E/SeVgkmwpiZ 2pFmwsPFrtx8gaWDsUo5JuxzwtmfYzo7rI4a9QztimqK6JvxV4Bz6r+BswFGkx+8 zmLZbkZoXynDH1d+d/x2yMw5re7s3tmhNso7JCDpv/BquEW1tGnJcUct1MJ8ybGp 3+mqbqTr4dY2/Wmt8+Yesl6DKSYvxT9HBmG2ZMU3/WNsxgP9vLI7bk0o3z0CCk11 Sh54ZDHHHOaX+Cd2ezqJKMmTJA32oWceoMTf7BDa+v5elkoaQQCECyILvcZsUPpC pvP4ij5Gly5txAFuwsYTBzcgErTsMyorar+ZQTes08i+mbMXc/SIIWQadu5030XP MrLi6vdvQRsBRcLQgUnd+wrqSGx/fi7PqXaEhKr2ZLLsC9Rc176Lv1AEg1dqSBP7 8/9HPXG/rEK9gfdCqSRPL2rdJLvDGoYGJ7zjWk5wyDoNvtxWROQE5LU0Vu+geRK8 1Tv2X1DlKrU06fgXbjo8px/UG/ZVq5cfqptbKaQaFRu1OxbUiZ4TVnFBgM/XpQjv WP/66UiP19xgWoRqR+Ax =+k18 -----END PGP SIGNATURE----- --V32M1hWVjliPHW+c--