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: <CACRpkdZYn8Ke2cXWt63LukTMa-zohToaK-UcrR3mvbCgL_M_yw@mail.gmail.com>
Date:   Wed, 21 Mar 2018 09:49:29 +0100
From:   Linus Walleij <linus.walleij@...aro.org>
To:     "A.s. Dong" <aisheng.dong@....com>
Cc:     Colin King <colin.king@...onical.com>,
        Fabio Estevam <festevam@...il.com>,
        Shawn Guo <shawnguo@...nel.org>,
        Stefan Agner <stefan@...er.ch>,
        "linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
        "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] pinctrl: imx: fix unsigned check if nfuncs with less than
 or equal zero

On Mon, Feb 26, 2018 at 2:14 PM, A.s. Dong <aisheng.dong@....com> wrote:

>> -     u32 nfuncs = 0;
>> -     u32 i = 0;
>> +     int nfuncs = 0;
>> +     int i = 0;
>>       bool flat_funcs;
>>
>
> I saw 'i', later used, is converted to u32 unconditionally. (GCC did not complain)
> e.g.
> radix_tree_insert
> imx_pinctrl_parse_functions
>
> And of_get_child_count seems can't  return a minor value.
>
> So does something like below look better?
>
> diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
> index c976ffe..4259209 100644
> --- a/drivers/pinctrl/freescale/pinctrl-imx.c
> +++ b/drivers/pinctrl/freescale/pinctrl-imx.c
> @@ -612,7 +612,7 @@ static int imx_pinctrl_probe_dt(struct platform_device *pdev,
>                 nfuncs = 1;
>         } else {
>                 nfuncs = of_get_child_count(np);
> -               if (nfuncs <= 0) {
> +               if (nfuncs == 0) {

This makes more sense to me.

You can have zero functions but not negative number of functions.

Aisheng, can you send a patch like this? (Or is it already somewhere in
my inbox?)

Yours,
Linus Walleij

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ