lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 01 Jul 2015 10:50:41 +0200
From:	SF Markus Elfring <elfring@...rs.sourceforge.net>
To:	Hal Rosenstock <hal.rosenstock@...il.com>,
	Roland Dreier <roland@...nel.org>,
	Sean Hefty <sean.hefty@...el.com>, linux-rdma@...r.kernel.org
CC:	LKML <linux-kernel@...r.kernel.org>,
	kernel-janitors@...r.kernel.org,
	Julia Lawall <julia.lawall@...6.fr>,
	Maninder Singh <maninder1.s@...sung.com>,
	Akhilesh Kumar <akhilesh.k@...sung.com>,
	David Miller <davem@...emloft.net>
Subject: Re: [PATCH] InfiniBand: Deletion of unnecessary checks before two
 function calls

> From: Markus Elfring <elfring@...rs.sourceforge.net>
> Date: Wed, 19 Nov 2014 19:19:21 +0100
> 
> The functions kfree() and pci_dev_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
>  drivers/infiniband/hw/mlx4/main.c         | 3 +--
>  drivers/infiniband/hw/mthca/mthca_reset.c | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index 8b72cf3..50dee1a 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -2512,8 +2512,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init)
>  		if (!dm[i]) {
>  			pr_err("failed to allocate memory for tunneling qp update work struct\n");
>  			for (i = 0; i < dev->caps.num_ports; i++) {
> -				if (dm[i])
> -					kfree(dm[i]);
> +				kfree(dm[i]);
>  			}
>  			goto out;
>  		}
> diff --git a/drivers/infiniband/hw/mthca/mthca_reset.c b/drivers/infiniband/hw/mthca/mthca_reset.c
> index 74c6a94..c521654 100644
> --- a/drivers/infiniband/hw/mthca/mthca_reset.c
> +++ b/drivers/infiniband/hw/mthca/mthca_reset.c
> @@ -279,8 +279,7 @@ good:
>  	}
>  
>  out:
> -	if (bridge)
> -		pci_dev_put(bridge);
> +	pci_dev_put(bridge);
>  	kfree(bridge_header);
>  	kfree(hca_header);
>  
> 

More software developers became interested in similar
source code improvements.

infiniband: Remove redundant NULL check before kfree
https://lkml.org/lkml/2015/6/26/45
https://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg919966.html

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists