[PATCH 3/4] mtd: onenand: samsung: Release memory after incorrect return/goto

Joe Perches joe at perches.com
Tue Jun 4 10:44:49 EDT 2013


The code uses

    return foo;
    goto err_type;

when instead the form should have been

    ret = foo;
    goto err_type;

Here this causes a useful kfree to be skipped.

Signed-off-by: Joe Perches <joe at perches.com>
---
 drivers/mtd/onenand/samsung.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/onenand/samsung.c b/drivers/mtd/onenand/samsung.c
index 2cf7408..90bd111 100644
--- a/drivers/mtd/onenand/samsung.c
+++ b/drivers/mtd/onenand/samsung.c
@@ -895,8 +895,8 @@ static int s3c_onenand_probe(struct platform_device *pdev)
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!r) {
 		dev_err(&pdev->dev, "no memory resource defined\n");
-		return -ENOENT;
-		goto ahb_resource_failed;
+		err = -ENOENT;
+		goto resource_failed;
 	}
 
 	onenand->base_res = request_mem_region(r->start, resource_size(r),
-- 
1.8.1.2.459.gbcd45b4.dirty




More information about the linux-mtd mailing list