Re: [PATCH v2] drivers/base/memory: make memory block get/put explicit

From: Mike Rapoport

Date: Tue May 12 2026 - 08:30:51 EST


On Tue, May 12, 2026 at 03:26:35PM +0800, Muchun Song wrote:
> Rename the memory block lookup helper to make the acquired reference
> explicit, add memory_block_put() to wrap put_device(), remove
> find_memory_block(), and use memory_block_get() as the single block-id
> based lookup interface.
>
> This makes it clearer to callers that a successful lookup holds a
> reference that must be dropped, reducing the chance of forgetting the
> matching put and leaking the memory block device reference.
>
> Link: https://lore.kernel.org/linux-mm/7887915D-E598-42B3-9AFE-BFFBACE8DE2D@xxxxxxxxx/#t
> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
> Acked-by: Oscar Salvador <osalvador@xxxxxxx>
> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> Acked-by: Michal Hocko <mhocko@xxxxxxxx>
> Tested-by: Donet Tom <donettom@xxxxxxxxxxxxx>
> Reviewed-by: Lorenzo Stoakes <ljs@xxxxxxxxxx>

Acked-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>

> ---
> Changes in v2:
> - mention the removal of find_memory_block() in the commit message
> - drop the redundant extern from the memory_block_get() declaration
> ---
> .../platforms/pseries/hotplug-memory.c | 14 ++-----
> drivers/base/memory.c | 38 +++++++------------
> drivers/base/node.c | 4 +-
> drivers/s390/char/sclp_mem.c | 17 ++++-----
> include/linux/memory.h | 7 +++-
> mm/memory_hotplug.c | 5 +--
> 6 files changed, 35 insertions(+), 50 deletions(-)

--
Sincerely yours,
Mike.