Skip to contentSkip to conversation

jz4740-adc: fix resource reclaim in jz4740_adc_probe error path

PATCH Superseded Axel Lin 2 participants 2 messages Jul 29, 2010 – Aug 1, 2010 Multifunction devices (MFD)

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 2/2 jz4740-adc: fix resource reclaim in jz4740_adc_probe error path

If mfd_add_devices() fail, we need to relese allocated resources.

---
This patch is against linux-next.

 drivers/mfd/jz4740-adc.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/mfd/jz4740-adc.c +7 -1
index 2846d24..3ad492c 100644
@@ -326,9 +326,15 @@ static int __devinit jz4740_adc_probe(struct platform_device *pdev)
 	writeb(0x00, adc->base + JZ_REG_ADC_ENABLE);
 	writeb(0xff, adc->base + JZ_REG_ADC_CTRL);
 
-	return mfd_add_devices(&pdev->dev, 0, jz4740_adc_cells,
+	ret = mfd_add_devices(&pdev->dev, 0, jz4740_adc_cells,
 		ARRAY_SIZE(jz4740_adc_cells), mem_base, adc->irq_base);
+	if (ret < 0)
+		goto err_clk_put;
 
+	return 0;
+
+err_clk_put:
+	clk_put(adc->clk);
 err_iounmap:
 	platform_set_drvdata(pdev, NULL);
 	iounmap(adc->base);
Signature · 1 line
1.5.4.3
#1 lore raw

Hi Axel,

Quoted 1 line · Axel Lin

If mfd_add_devices() fail, we need to relese allocated resources.

Patch applied, thanks a lot.

Cheers,
Samuel.

Quoted 32 lines

---
This patch is against linux-next.

 drivers/mfd/jz4740-adc.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/mfd/jz4740-adc.c +7 -1
index 2846d24..3ad492c 100644
@@ -326,9 +326,15 @@ static int __devinit jz4740_adc_probe(struct platform_device *pdev)
 	writeb(0x00, adc->base + JZ_REG_ADC_ENABLE);
 	writeb(0xff, adc->base + JZ_REG_ADC_CTRL);
 
-	return mfd_add_devices(&pdev->dev, 0, jz4740_adc_cells,
+	ret = mfd_add_devices(&pdev->dev, 0, jz4740_adc_cells,
 		ARRAY_SIZE(jz4740_adc_cells), mem_base, adc->irq_base);
+	if (ret < 0)
+		goto err_clk_put;
 
+	return 0;
+
+err_clk_put:
+	clk_put(adc->clk);
 err_iounmap:
 	platform_set_drvdata(pdev, NULL);
 	iounmap(adc->base);
Signature · 1 line
1.5.4.3
Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/