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]
Message-ID: <152182210780.178046.13284917877743312593@swboyd.mtv.corp.google.com>
Date:   Fri, 23 Mar 2018 09:21:47 -0700
From:   Stephen Boyd <swboyd@...omium.org>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Timur Tabi <timur@...eaurora.org>
Cc:     Stephen Boyd <sboyd@...eaurora.org>, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, devicetree@...r.kernel.org,
        linux-arm-msm@...r.kernel.org,
        Bjorn Andersson <bjorn.andersson@...aro.org>,
        Grant Likely <grant.likely@...retlab.ca>,
        linux-gpio@...r.kernel.org
Subject: Re: [PATCH v3 3/3] pinctrl: qcom: Don't allow protected pins to be requested

Quoting Andy Shevchenko (2018-03-23 04:36:04)
> On Thu, 2018-03-22 at 19:16 -0500, Timur Tabi wrote:
> > On 03/21/2018 11:58 AM, Stephen Boyd wrote:
> > > +static int msm_gpio_init_valid_mask(struct gpio_chip *chip,
> > > +                               struct msm_pinctrl *pctrl)
> > > +{
> > > +   int ret;
> > > +   unsigned int len, i;
> > > +   unsigned int max_gpios = pctrl->soc->ngpios;
> > > +
> > > +   /* The number of GPIOs in the ACPI tables */
> > > +   ret = device_property_read_u16_array(pctrl->dev, "gpios",
> > > NULL, 0);
> > > +   if (ret > 0 && ret < max_gpios) {
> > 
> > This needs to be ret <= max_gpios, otherwise it will fail if every
> > GPIO 
> > is available.
> > 
> > And it should print an error message and return an error code if ret
> > > 
> > max_gpios.
> 
> Perhaps makes sense to do the opposite condition
> 
> if (ret < 0 || ret > max_gpios) {
>  ... error handling ...
> }
> 

Indeed. I already rewrote it like this two days ago:

static int msm_gpio_init_valid_mask(struct gpio_chip *chip,
                                   struct msm_pinctrl *pctrl)
{
       int ret;
       unsigned int len, i;
       unsigned int max_gpios = pctrl->soc->ngpios;
       u16 *tmp;

       /* The number of GPIOs in the ACPI tables */
       len = ret = device_property_read_u16_array(pctrl->dev, "gpios",
ULL, 0);
       if (ret < 0)
               return 0;

       if (ret > max_gpios)
               return -EINVAL;

       tmp = kmalloc_array(len, sizeof(*tmp), GFP_KERNEL);
       if (!tmp)
               return -ENOMEM;

       ret = device_property_read_u16_array(pctrl->dev, "gpios", tmp,
en);
       if (ret < 0) {
               dev_err(pctrl->dev, "could not read list of GPIOs\n");
               goto out;
       }

       bitmap_zero(chip->valid_mask, max_gpios);
       for (i = 0; i < len; i++)
               set_bit(tmp[i], chip->valid_mask);

out:
       kfree(tmp);
       return ret;
}

I'll send the updated patches now.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ