[PATCH] mm,memory_hotplug: set failure reason in offline_pages()

Dan Carpenter posted 1 patch 3 months, 2 weeks ago
There is a newer version of this series
mm/memory_hotplug.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] mm,memory_hotplug: set failure reason in offline_pages()
Posted by Dan Carpenter 3 months, 2 weeks ago
The "reason" variable is uninitialized on this error path.  It's supposed
to explain why the function failed.

Fixes: e4e2806b639c ("mm,memory_hotplug: implement numa node notifier")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 mm/memory_hotplug.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 4d864b4fb891..e954f81b55a0 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1977,8 +1977,10 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages,
 		node_arg.nid = node;
 		ret = node_notify(NODE_REMOVING_LAST_MEMORY, &node_arg);
 		ret = notifier_to_errno(ret);
-		if (ret)
+		if (ret) {
+			reason = "nr_pages more than present_pages";
 			goto failed_removal_isolated;
+		}
 	}
 
 	ret = memory_notify(MEM_GOING_OFFLINE, &mem_arg);
Re: [PATCH] mm,memory_hotplug: set failure reason in offline_pages()
Posted by David Hildenbrand 3 months, 2 weeks ago
On 25.06.25 17:22, Dan Carpenter wrote:
> The "reason" variable is uninitialized on this error path.  It's supposed
> to explain why the function failed.
> 
> Fixes: e4e2806b639c ("mm,memory_hotplug: implement numa node notifier")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>   mm/memory_hotplug.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 4d864b4fb891..e954f81b55a0 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1977,8 +1977,10 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages,
>   		node_arg.nid = node;
>   		ret = node_notify(NODE_REMOVING_LAST_MEMORY, &node_arg);
>   		ret = notifier_to_errno(ret);
> -		if (ret)
> +		if (ret) {
> +			reason = "nr_pages more than present_pages";

"node notifier failure"

With that

Acked-by: David Hildenbrand <david@redhat.com>

(likely should be squashed because the commit it might not be stable yet)

-- 
Cheers,

David / dhildenb
Re: [PATCH] mm,memory_hotplug: set failure reason in offline_pages()
Posted by Dan Carpenter 3 months, 2 weeks ago
On Wed, Jun 25, 2025 at 05:24:01PM +0200, David Hildenbrand wrote:
> On 25.06.25 17:22, Dan Carpenter wrote:
> > The "reason" variable is uninitialized on this error path.  It's supposed
> > to explain why the function failed.
> > 
> > Fixes: e4e2806b639c ("mm,memory_hotplug: implement numa node notifier")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> >   mm/memory_hotplug.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> > index 4d864b4fb891..e954f81b55a0 100644
> > --- a/mm/memory_hotplug.c
> > +++ b/mm/memory_hotplug.c
> > @@ -1977,8 +1977,10 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages,
> >   		node_arg.nid = node;
> >   		ret = node_notify(NODE_REMOVING_LAST_MEMORY, &node_arg);
> >   		ret = notifier_to_errno(ret);
> > -		if (ret)
> > +		if (ret) {
> > +			reason = "nr_pages more than present_pages";
> 
> "node notifier failure"
> 
> With that
> 
> Acked-by: David Hildenbrand <david@redhat.com>
> 
> (likely should be squashed because the commit it might not be stable yet)

Oh, yeah.  I misread the code.  Thanks.  I resent now.

But, ugh, I forgot to add your Acked-by...  But this is likely going
to be squashed as you say so hopefully that's fine.

regards,
dan carpenter