Patch "pinctrl: ralink: Check for null return of devm_kcalloc" has been added to the 5.18-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

    pinctrl: ralink: Check for null return of devm_kcalloc

to the 5.18-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:
     pinctrl-ralink-check-for-null-return-of-devm_kcalloc.patch
and it can be found in the queue-5.18 subdirectory.

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



commit fca1b7c10ba41f30f82bf0da0192a500718d82b2
Author: William Dean <williamsukatube@xxxxxxxxx>
Date:   Sun Jul 10 23:49:22 2022 +0800

    pinctrl: ralink: Check for null return of devm_kcalloc
    
    [ Upstream commit c3b821e8e406d5650e587b7ac624ac24e9b780a8 ]
    
    Because of the possible failure of the allocation, data->domains might
    be NULL pointer and will cause the dereference of the NULL pointer
    later.
    Therefore, it might be better to check it and directly return -ENOMEM
    without releasing data manually if fails, because the comment of the
    devm_kmalloc() says "Memory allocated with this function is
    automatically freed on driver detach.".
    
    Fixes: a86854d0c599b ("treewide: devm_kzalloc() -> devm_kcalloc()")
    Reported-by: Hacash Robot <hacashRobot@xxxxxxxxxxx>
    Signed-off-by: William Dean <williamsukatube@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20220710154922.2610876-1-williamsukatube@xxxxxxx
    Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pinctrl/ralink/pinctrl-ralink.c b/drivers/pinctrl/ralink/pinctrl-ralink.c
index 841f23f55c95..3a8268a43d74 100644
--- a/drivers/pinctrl/ralink/pinctrl-ralink.c
+++ b/drivers/pinctrl/ralink/pinctrl-ralink.c
@@ -266,6 +266,8 @@ static int ralink_pinmux_pins(struct ralink_priv *p)
 						p->func[i]->pin_count,
 						sizeof(int),
 						GFP_KERNEL);
+		if (!p->func[i]->pins)
+			return -ENOMEM;
 		for (j = 0; j < p->func[i]->pin_count; j++)
 			p->func[i]->pins[j] = p->func[i]->pin_first + j;
 



[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