From: Greg KH <gregkh@linuxfoundation.org>
To: Zijun Hu <quic_zijuhu@quicinc.com>
Cc: rafael@kernel.org, andriy.shevchenko@linux.intel.com,
brgl@bgdev.pl, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] devres: Fix devm_krealloc() allocating memory with wrong size
Date: Sun, 16 Jun 2024 12:02:48 +0200 [thread overview]
Message-ID: <2024061609-breezy-magnitude-8edf@gregkh> (raw)
In-Reply-To: <1718531655-29761-1-git-send-email-quic_zijuhu@quicinc.com>
On Sun, Jun 16, 2024 at 05:54:15PM +0800, Zijun Hu wrote:
> Kernel API devm_krealloc() calls alloc_dr() with wrong argument
> @total_new_size, and it will cause more memory to be allocated
> than required, fixed by using @new_size as alloc_dr()'s argument.
>
> Fixes: f82485722e5d ("devres: provide devm_krealloc()")
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> drivers/base/devres.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
> index 3df0025d12aa..1cf87ddf1f55 100644
> --- a/drivers/base/devres.c
> +++ b/drivers/base/devres.c
> @@ -898,7 +898,7 @@ void *devm_krealloc(struct device *dev, void *ptr, size_t new_size, gfp_t gfp)
> * taking the lock as most probably the caller uses GFP_KERNEL.
> */
> new_dr = alloc_dr(devm_kmalloc_release,
> - total_new_size, gfp, dev_to_node(dev));
> + new_size, gfp, dev_to_node(dev));
Wait, are you sure? Did you properly test this? What is the actual
savings and how do you handle the fact that you are now not allocating
the space reserved for the devres structure itself?
thanks,
greg k-h
next prev parent reply other threads:[~2024-06-16 10:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-16 9:54 [PATCH v1] devres: Fix devm_krealloc() allocating memory with wrong size Zijun Hu
2024-06-16 9:58 ` Greg KH
2024-06-16 10:02 ` Greg KH [this message]
2024-06-16 10:10 ` quic_zijuhu
2024-06-16 10:17 ` Greg KH
2024-06-16 10:22 ` quic_zijuhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2024061609-breezy-magnitude-8edf@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_zijuhu@quicinc.com \
--cc=rafael@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.