Re: [PATCH] devres: update node debug info on in-place devm_krealloc()

From: Andy Shevchenko

Date: Fri Dec 04 2026 - 04:13:37 EST


On Fri, Dec 04, 2026 at 08:39:19AM +0800, Eric Yun Lin Chiang wrote:
> On Thu, Dec 03, 2026 at 01:42:35PM +0200, Andy Shevchenko wrote:
> > 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.
>
> devm_krealloc() accepts a smaller size and returns the same pointer,
> like krealloc() does, but no memory is given back. My changelog said
> "shrunk", which made it sound otherwise.
>
> The patch only changes the size recorded in the node's debug info, so
> on its own it only changes debug output, which is not much of a reason.
> I wrote it as groundwork for letting KASAN check devres allocations
> against the requested size rather than the rounded-up bucket, and I
> should not have sent it without that context. Please consider this one
> withdrawn. I will come back with the KASAN part as one RFC series,
> together with a concrete case it catches.

Doesn't matter. We should not lie to the users of the traces. If size was not
shrunk, it is not changed based on what the caller of krealloc() asked for.
If you want to add that to the trace, it should be an additional field or
so, not the lie. OTOH you can introduce memory shrinking support to krealloc()
but I have no idea what will be a perception of any of these approaches.

--
With Best Regards,
Andy Shevchenko