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: <20220425172159.5u6q74gd2cmmipzd@pengutronix.de>
Date:   Mon, 25 Apr 2022 19:21:59 +0200
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Yihao Han <hanyihao@...o.com>
Cc:     Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Cornelia Huck <cohuck@...hat.com>,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        Stefan Richter <stefanr@...6.in-berlin.de>,
        Corentin Labbe <clabbe@...libre.com>,
        linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
        kernel@...o.com
Subject: Re: [PATCH v2] macintosh: macio_asic: fix resource_size.cocci
 warnings

On Thu, Apr 21, 2022 at 07:18:07AM -0700, Yihao Han wrote:
> drivers/macintosh/macio_asic.c:219:26-29: WARNING:Suspicious code. resource_size is maybe missing with res
> drivers/macintosh/macio_asic.c:221:26-29: WARNING:Suspicious code. resource_size is maybe missing with res
> 
> Use resource_size function on resource object instead of
> explicit computation.
> 
> Generated by: scripts/coccinelle/api/resource_size.cocci
> 
> Signed-off-by: Yihao Han <hanyihao@...o.com>
> ---
> v2: drop parenthesis around resource_size(res) and edit commit message
> ---
>  drivers/macintosh/macio_asic.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
> index 1943a007e2d5..260fccb3863e 100644
> --- a/drivers/macintosh/macio_asic.c
> +++ b/drivers/macintosh/macio_asic.c
> @@ -216,9 +216,9 @@ static int macio_resource_quirks(struct device_node *np, struct resource *res,
>  	/* Some older IDE resources have bogus sizes */
>  	if (of_node_name_eq(np, "IDE") || of_node_name_eq(np, "ATA") ||
>  	    of_node_is_type(np, "ide") || of_node_is_type(np, "ata")) {
> -		if (index == 0 && (res->end - res->start) > 0xfff)
> +		if (index == 0 && resource_size(res) > 0xfff)

Michael Ellerman noted in the v1 thread, that this is wrong as
resource_size evaluates to end - start + 1. So this has to be

		if (index == 0 && resource_size(res) > 0x1000)

to be equivalent.

>  			res->end = res->start + 0xfff;
> -		if (index == 1 && (res->end - res->start) > 0xff)
> +		if (index == 1 && resource_size(res) > 0xff)

Similar here.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ