Skip to contentSkip to conversation

dmaengine: qcom_hidma: avoid freeing an uninitialized pointer

PATCH Applied Anton Vasilyev 3 participants 3 messages Aug 10, 2017 – Aug 21, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: qcom_hidma: avoid freeing an uninitialized pointer

If device_node np doesn't contain child or first child doesn't have property "reg" then hidma_mgmt_of_populate_channels() perfoms deallocation on uninitialized local variable res.

The patch adds res initialization by NULL.

Found by Linux Driver Verification project (linuxtesting.org).

---
 drivers/dma/qcom/hidma_mgmt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/qcom/hidma_mgmt.c +1 -1
index 5a0991b..89e36e3 100644
@@ -354,7 +354,7 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np)
 	struct platform_device_info pdevinfo;
 	struct of_phandle_args out_irq;
 	struct device_node *child;
-	struct resource *res;
+	struct resource *res = NULL;
 	const __be32 *cell;
 	int ret = 0, size, i, num;
 	u64 addr, addr_size;
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Anton Vasilyev

If device_node np doesn't contain child or first child doesn't have property "reg" then hidma_mgmt_of_populate_channels() perfoms deallocation on uninitialized local variable res.

The patch adds res initialization by NULL.

Found by Linux Driver Verification project (linuxtesting.org).

---
 drivers/dma/qcom/hidma_mgmt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/qcom/hidma_mgmt.c +0 -0
index 5a0991b..89e36e3 100644

drivers/dma/qcom/hidma_mgmt.c static int __init hidma_mgmt_of_populate_channels(struct device_node *np) · line 360

Quoted 8 lines
drivers/dma/qcom/hidma_mgmt.c +1 -1
@@ -354,7 +354,7 @@ static int __init hidma_mgmt_of_populate_channels(struct device_node *np)
 	struct platform_device_info pdevinfo;
 	struct of_phandle_args out_irq;
 	struct device_node *child;
-	struct resource *res;
+	struct resource *res = NULL;
 	const __be32 *cell;
 	int ret = 0, size, i, num;
 	u64 addr, addr_size;
Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Applied
#2 lore raw
In reply to Anton Vasilyev
Quoted 7 lines · Anton Vasilyev

If device_node np doesn't contain child or first child doesn't have property "reg" then hidma_mgmt_of_populate_channels() perfoms deallocation on uninitialized local variable res.

The patch adds res initialization by NULL.

Found by Linux Driver Verification project (linuxtesting.org).

Applied, thanks

Signature · 1 line
~Vinod