Patch "Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name()" has been added to the 6.11-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

    Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name()

to the 6.11-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:
     bluetooth-btbcm-fix-missing-of_node_put-in-btbcm_get.patch
and it can be found in the queue-6.11 subdirectory.

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



commit 5c2d27e15e9276cc213e6c24543a189adb4f1818
Author: Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx>
Date:   Thu Oct 31 13:11:23 2024 +0100

    Bluetooth: btbcm: fix missing of_node_put() in btbcm_get_board_name()
    
    [ Upstream commit e42eec0f182ac0605e658145f6fe3b6a7c256c45 ]
    
    of_find_node_by_path() returns a pointer to a device_node with its
    refcount incremented, and a call to of_node_put() is required to
    decrement the refcount again and avoid leaking the resource.
    
    If 'of_property_read_string_index(root, "compatible", 0, &tmp)' fails,
    the function returns without calling of_node_put(root) before doing so.
    
    The automatic cleanup attribute can be used by means of the __free()
    macro to automatically call of_node_put() when the variable goes out of
    scope, fixing the issue and also accounting for new error paths.
    
    Fixes: 63fac3343b99 ("Bluetooth: btbcm: Support per-board firmware variants")
    Signed-off-by: Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index f9a7c790d7e2e..723db989d9cec 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -541,11 +541,10 @@ static const struct bcm_subver_table bcm_usb_subver_table[] = {
 static const char *btbcm_get_board_name(struct device *dev)
 {
 #ifdef CONFIG_OF
-	struct device_node *root;
+	struct device_node *root __free(device_node) = of_find_node_by_path("/");
 	char *board_type;
 	const char *tmp;
 
-	root = of_find_node_by_path("/");
 	if (!root)
 		return NULL;
 
@@ -555,7 +554,6 @@ static const char *btbcm_get_board_name(struct device *dev)
 	/* get rid of any '/' in the compatible string */
 	board_type = devm_kstrdup(dev, tmp, GFP_KERNEL);
 	strreplace(board_type, '/', '-');
-	of_node_put(root);
 
 	return board_type;
 #else




[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