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: <CAMRc=Me66Yi-zXVEOgHW3m_TtaEAz4QMQUJRjeS0WKayJBHC9w@mail.gmail.com>
Date:   Tue, 14 Jul 2020 16:48:29 +0200
From:   Bartosz Golaszewski <brgl@...ev.pl>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     Jonathan Cameron <jic23@...nel.org>,
        Hartmut Knaack <knaack.h@....de>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>,
        Michal Simek <michal.simek@...inx.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Guenter Roeck <linux@...ck-us.net>,
        linux-iio <linux-iio@...r.kernel.org>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: Re: [PATCH v4 1/3] devres: provide devm_krealloc()

On Mon, Jul 13, 2020 at 9:29 PM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> On Mon, Jul 13, 2020 at 04:59:32PM +0200, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bgolaszewski@...libre.com>
> >
> > Implement the managed variant of krealloc(). This function works with
> > all memory allocated by devm_kmalloc() (or devres functions using it
> > implicitly like devm_kmemdup(), devm_kstrdup() etc.).
> >
> > Managed realloc'ed chunks can be manually released with devm_kfree().
> >
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
> > ---
> >  .../driver-api/driver-model/devres.rst        |  1 +
> >  drivers/base/devres.c                         | 67 +++++++++++++++++++
> >  include/linux/device.h                        |  2 +
> >  3 files changed, 70 insertions(+)
> >
> > diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentation/driver-api/driver-model/devres.rst
> > index eaaaafc21134f..f318a5c0033c1 100644
> > --- a/Documentation/driver-api/driver-model/devres.rst
> > +++ b/Documentation/driver-api/driver-model/devres.rst
> > @@ -354,6 +354,7 @@ MEM
> >    devm_kmalloc()
> >    devm_kmalloc_array()
> >    devm_kmemdup()
> > +  devm_krealloc()
> >    devm_kstrdup()
> >    devm_kvasprintf()
> >    devm_kzalloc()
> > diff --git a/drivers/base/devres.c b/drivers/base/devres.c
> > index ed615d3b9cf15..1775d35462300 100644
> > --- a/drivers/base/devres.c
> > +++ b/drivers/base/devres.c
> > @@ -837,6 +837,73 @@ void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp)
> >  }
> >  EXPORT_SYMBOL_GPL(devm_kmalloc);
> >
> > +/**
> > + * devm_krealloc - Resource-managed krealloc()
> > + * @dev: Device to re-allocate memory for
> > + * @ptr: Pointer to the memory chunk to re-allocate
> > + * @new_size: New allocation size
> > + * @gfp: Allocation gfp flags
> > + *
> > + * Managed krealloc(). Resizes the memory chunk allocated with devm_kmalloc().
> > + * Behaves similarly to regular krealloc(): if @ptr is NULL or ZERO_SIZE_PTR,
> > + * it's the equivalent of devm_kmalloc(). If new_size is zero, it returns
>
> 'it frees the previously allocated memory and returns'
>
> > + * ZERO_SIZE_PTR. This function doesn't change the order in which the release
> > + * callback for the re-alloc'ed devres will be called (except when falling back
> > + * to devm_kmalloc()
>
> 'or when freeing resources when new_size is zero'
>

This is nit-picking but ok. :)

[snip!]

> > +++ b/include/linux/device.h
> > @@ -206,6 +206,8 @@ int devres_release_group(struct device *dev, void *id);
> >
> >  /* managed devm_k.alloc/kfree for device drivers */
> >  void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp) __malloc;
>
> > +void *devm_krealloc(struct device *dev, void *ptr, size_t size,
> > +                 gfp_t gfp) __must_check;
>
> Strange indentation, also you can move __must_check to the beginning of the
> declaration.
>

There's nothing wrong with this indentation, what do you mean?
__must_check is usually put at the end of the line.

[snip!]

Bart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ