Re: [PATCH] devres: update node debug info on in-place devm_krealloc()
From: Andy Shevchenko
Date: Thu Dec 03 2026 - 06:42:55 EST
On Thu, Dec 03, 2026 at 08:57:04AM +0800, Eric Yun Lin Chiang wrote:
> When the new size still fits in the existing allocation,
> devm_krealloc() returns the old pointer without touching the node's
> debug info, so the node keeps the size of the original request.
> devres_log() and the devres_log tracepoint then report a stale size
> for the resource: a buffer grown in place from 1000 to 1500 bytes, or
> shrunk to 600 bytes, is still reported as 1000 bytes.
Do we really support shrinking for realloc() in kernel?
I am under the impression that we don't, so in such a case info should
not be updated. Please, check this and confirm.
> Commit f813ec9e84b4 ("devres: fix missing node debug info in
> devm_krealloc()") added the debug info for nodes newly allocated by
> devm_krealloc(); do the same on the in-place path, so the recorded
> size always matches the size the caller asked for.
...
> /*
> * If new size is smaller or equal to the actual number of bytes
> - * allocated previously - just return the same pointer.
> + * allocated previously - just update the node's debug info and
> + * return the same pointer.
> */
> - if (total_new_size <= total_old_size)
> + if (total_new_size <= total_old_size) {
> + devres_set_node_dbginfo(&container_of(ptr, struct devres, data)->node,
> + "devm_krealloc_release", new_size);
> return ptr;
> + }
If I'm right, this patch is bogus.
--
With Best Regards,
Andy Shevchenko