iommu/ipmmu-vmsa: Avoid leak OF node on error
PATCH 1/1 iommu/ipmmu-vmsa: Avoid leak OF node on error
From: Minghao Chi <[email protected]>
The OF node should be put before returning error in ipmmu_init(), otherwise node's refcount will be leaked.
--- drivers/iommu/ipmmu-vmsa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/iommu/ipmmu-vmsa.c +1 -2
@@ -1179,11 +1179,10 @@ static int __init ipmmu_init(void)return 0 ; np =of_find_matching_node (NULL , ipmmu_of_ids); +of_node_put (np);if (!np)return 0 ; -of_node_put (np); - ret =platform_driver_register (&ipmmu_driver);if (ret <0 )return ret;
Signature · 7 lines
2.25.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu
Johan Hovold
NAKQuoted 18 lines · On Mon, May 23, 2022 at 11:11:45AM +0000, [email protected] wrote:
From: Minghao Chi <[email protected]>
The OF node should be put before returning error in
ipmmu_init(), otherwise node's refcount will be leaked.Reported-by Zeal Robot <[email protected]>Signed-off-by Minghao Chi <[email protected]>--- drivers/iommu/ipmmu-vmsa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/iommu/ipmmu-vmsa.c +0
-0@@ -1179,11 +1179,10 @@ static int __init ipmmu_init(void)return 0 ;
drivers/iommu/ipmmu-vmsa.c static int __init ipmmu_init(void) · line 1188
Quoted 10 lines
drivers/iommu/ipmmu-vmsa.c +1
-2np =of_find_matching_node (NULL , ipmmu_of_ids); +of_node_put (np);if (!np)return 0 ; -of_node_put (np); - ret =platform_driver_register (&ipmmu_driver);if (ret <0 )return ret;
NAK
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Robin Murphy
reviewerQuoted 24 lines · Johan Hovold
Quoted 23 lines · On Mon, May 23, 2022 at 11:11:45AM +0000, [email protected] wrote:
From: Minghao Chi <[email protected]>
The OF node should be put before returning error in
ipmmu_init(), otherwise node's refcount will be leaked.Reported-by Zeal Robot <[email protected]>Signed-off-by Minghao Chi <[email protected]>--- drivers/iommu/ipmmu-vmsa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/iommu/ipmmu-vmsa.c +1
-0@@ -1179,11 +1179,10 @@ static int __init ipmmu_init(void)return 0 ; np =of_find_matching_node (NULL , ipmmu_of_ids); +of_node_put (np);if (!np)return 0 ;
Quoted 7 lines
drivers/iommu/ipmmu-vmsa.c static int __init ipmmu_init(void) · line 1188
Quoted 5 lines
drivers/iommu/ipmmu-vmsa.c +0
-2-of_node_put (np); - ret =platform_driver_register (&ipmmu_driver);if (ret <0 )return ret;NAK
Indeed. How exactly can we hold a refcount on NULL, let alone leak it?
Static checkers are great for flagging up code that *might* have issues, but please actually *look* at the code and apply some thought before sending a patch.
Robin.
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu