Patch "mm/hugetlb: fix potential double free in hugetlb_register_node() error path" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    mm/hugetlb: fix potential double free in hugetlb_register_node() error path

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mm-hugetlb-fix-potential-double-free-in-hugetlb_regi.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit dd75d8c63ea2cb07a6e534fd20ac8325ac73e020
Author: Miaohe Lin <linmiaohe@xxxxxxxxxx>
Date:   Wed Feb 24 12:06:50 2021 -0800

    mm/hugetlb: fix potential double free in hugetlb_register_node() error path
    
    [ Upstream commit cc2205a67dec5a700227a693fc113441e73e4641 ]
    
    In hugetlb_sysfs_add_hstate(), we would do kobject_put() on hstate_kobjs
    when failed to create sysfs group but forget to set hstate_kobjs to NULL.
    Then in hugetlb_register_node() error path, we may free it again via
    hugetlb_unregister_node().
    
    Link: https://lkml.kernel.org/r/20210107123249.36964-1-linmiaohe@xxxxxxxxxx
    Fixes: a3437870160c ("hugetlb: new sysfs interface")
    Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx>
    Reviewed-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
    Reviewed-by: Muchun Song <smuchun@xxxxxxxxx>
    Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 26909396898b6..afe803dbcab1b 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2984,8 +2984,10 @@ static int hugetlb_sysfs_add_hstate(struct hstate *h, struct kobject *parent,
 		return -ENOMEM;
 
 	retval = sysfs_create_group(hstate_kobjs[hi], hstate_attr_group);
-	if (retval)
+	if (retval) {
 		kobject_put(hstate_kobjs[hi]);
+		hstate_kobjs[hi] = NULL;
+	}
 
 	return retval;
 }



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux