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] [day] [month] [year] [list]
Message-ID: <20230614125304.294dd2ef@kernel.org>
Date: Wed, 14 Jun 2023 12:53:04 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Jiasheng Jiang <jiasheng@...as.ac.cn>
Cc: vburru@...vell.com, aayarekar@...vell.com, davem@...emloft.net,
 edumazet@...gle.com, pabeni@...hat.com, sburla@...vell.com,
 netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] octeon_ep: Add missing check for ioremap

On Wed, 14 Jun 2023 11:23:47 +0800 Jiasheng Jiang wrote:
> @@ -981,6 +981,9 @@ int octep_device_setup(struct octep_device *oct)
>  		oct->mmio[i].hw_addr =
>  			ioremap(pci_resource_start(oct->pdev, i * 2),
>  				pci_resource_len(oct->pdev, i * 2));
> +		if (!oct->mmio[i].hw_addr)
> +			goto unsupported_dev;
> +
>  		oct->mmio[i].mapped = 1;
>  	}
>  
> @@ -1015,8 +1018,8 @@ int octep_device_setup(struct octep_device *oct)
>  	return 0;
>  
>  unsupported_dev:
> -	for (i = 0; i < OCTEP_MMIO_REGIONS; i++)
> -		iounmap(oct->mmio[i].hw_addr);
> +	for (j = 0; j < i; j++)
> +		iounmap(oct->mmio[j].hw_addr);

Assuming @i is not changed by the rest of the function is a bit fragile.

Better way of handling this situation is:

unsupported_dev:
	i = OCTEP_MMIO_REGIONS;
unmap_prev:
	while (i--)
		iounmap(oct->mmio[i].hw_addr);

and jump to unmap_prev
-- 
pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ