* [PATCH] hugetlb: Fix possible deadlock
@ 2026-03-25 0:46 Ethan Tidmore
2026-03-25 2:01 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Ethan Tidmore @ 2026-03-25 0:46 UTC (permalink / raw)
To: Mina Almasry, Muchun Song, Oscar Salvador, Andrew Morton
Cc: David Hildenbrand, Mike Kravetz, David Rientjes, linux-mm,
linux-kernel, Ethan Tidmore
In allocate_file_region_entries() error path the function region_chg()
returns but does not release the lock 'resv->lock'.
Release lock 'resv->lock' before returning.
Fixes: 0db9d74ed8845 ("hugetlb: disable region_add file_region coalescing")
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
mm/hugetlb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index d6ea11113f1d..230fd8c63588 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -807,8 +807,10 @@ static long region_chg(struct resv_map *resv, long f, long t,
if (*out_regions_needed == 0)
*out_regions_needed = 1;
- if (allocate_file_region_entries(resv, *out_regions_needed))
+ if (allocate_file_region_entries(resv, *out_regions_needed)) {
+ spin_unlock(&resv->lock);
return -ENOMEM;
+ }
resv->adds_in_progress += *out_regions_needed;
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hugetlb: Fix possible deadlock
2026-03-25 0:46 [PATCH] hugetlb: Fix possible deadlock Ethan Tidmore
@ 2026-03-25 2:01 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2026-03-25 2:01 UTC (permalink / raw)
To: Ethan Tidmore
Cc: Mina Almasry, Muchun Song, Oscar Salvador, David Hildenbrand,
Mike Kravetz, David Rientjes, linux-mm, linux-kernel
On Tue, 24 Mar 2026 19:46:53 -0500 Ethan Tidmore <ethantidmore06@gmail.com> wrote:
> In allocate_file_region_entries() error path the function region_chg()
> returns but does not release the lock 'resv->lock'.
>
> Release lock 'resv->lock' before returning.
>
> ...
>
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -807,8 +807,10 @@ static long region_chg(struct resv_map *resv, long f, long t,
> if (*out_regions_needed == 0)
> *out_regions_needed = 1;
>
> - if (allocate_file_region_entries(resv, *out_regions_needed))
> + if (allocate_file_region_entries(resv, *out_regions_needed)) {
> + spin_unlock(&resv->lock);
> return -ENOMEM;
> + }
>
> resv->adds_in_progress += *out_regions_needed;
Thanks, but please see how allocate_file_region_entries() leaves the
lock unheld if it's going to return -ENOMEM.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-25 2:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25 0:46 [PATCH] hugetlb: Fix possible deadlock Ethan Tidmore
2026-03-25 2:01 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox