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: <ZLpaeHlJujd8l0DS@smile.fi.intel.com>
Date:   Fri, 21 Jul 2023 13:14:16 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Nuno Sá <noname.nuno@...il.com>
Cc:     linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>
Subject: Re: [PATCH v1 3/8] iio: core: Switch to krealloc_array()

On Fri, Jul 21, 2023 at 09:59:37AM +0200, Nuno Sá wrote:
> On Thu, 2023-07-20 at 23:53 +0300, Andy Shevchenko wrote:

...

> > +       struct attribute **attrs, **attr, *clk = NULL;
> >         struct iio_dev_attr *p;
> > -       struct attribute **attr, *clk = NULL;
> >  
> >         /* First count elements in any existing group */
> > -       if (indio_dev->info->attrs) {
> > -               attr = indio_dev->info->attrs->attrs;
> > -               while (*attr++ != NULL)
> > +       attrs = indio_dev->info->attrs ? indio_dev->info->attrs->attrs : NULL;
> > +       if (attrs) {
> > +               for (attr = attrs; *attr; attr++)
> >                         attrcount_orig++;

> not really related with the change... maybe just mention it in the commit?

Hmm... It's related to make krealloc_array() to work as expected.

> >         }

...

> >         iio_dev_opaque->chan_attr_group.attrs =
> > -               kcalloc(attrcount + 1,
> > -                       sizeof(iio_dev_opaque->chan_attr_group.attrs[0]),
> > -                       GFP_KERNEL);
> > +               krealloc_array(attrs, attrcount + 1, sizeof(*attrs),
> > GFP_KERNEL);
> >         if (iio_dev_opaque->chan_attr_group.attrs == NULL) {
> 
> since you're here and you also already did some style cleanups above, maybe
> change it to 'if (!iio_dev_opaque->chan_attr_group.attrs)'?

I don't think it's related (but you can tell that this check related to
the allocator, and since we touch it, we may touch this), if Jonathan
wants this, I definitely do.

...

Thank you for the review!

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ