aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2011-11-28 08:53:13 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-01-09 13:07:32 -0500
commitb49e345e61a2e0c4decbe9b1bd670ed5599fac6e (patch)
treee125dca29028b59322fe3b7bb096b4191bff0791 /drivers/mtd
parent5d3667eee40a88f79f7f826f0b4c3c9647d7ea7a (diff)
mtd: docg3: dereferencing an ERR_PTR() in docg3_probe()
If doc_probe_device() returned an ERR_PTR, then we accidentally saved that to docg3_floors[floor] = mtd; which gets derefenced in the error handling when we call doc_release_device(). I've reworked the error handling to take care of that and hopefully make it a little simpler. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/devices/docg3.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index d7df3114aa1..f7490a014e7 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -2027,21 +2027,24 @@ static int __init docg3_probe(struct platform_device *pdev)
2027 if (!docg3_bch) 2027 if (!docg3_bch)
2028 goto nomem2; 2028 goto nomem2;
2029 2029
2030 ret = 0;
2031 for (floor = 0; floor < DOC_MAX_NBFLOORS; floor++) { 2030 for (floor = 0; floor < DOC_MAX_NBFLOORS; floor++) {
2032 mtd = doc_probe_device(base, floor, dev); 2031 mtd = doc_probe_device(base, floor, dev);
2033 if (floor == 0 && !mtd) 2032 if (IS_ERR(mtd)) {
2034 goto notfound;
2035 if (!IS_ERR_OR_NULL(mtd))
2036 ret = mtd_device_parse_register(mtd, part_probes,
2037 NULL, NULL, 0);
2038 else
2039 ret = PTR_ERR(mtd); 2033 ret = PTR_ERR(mtd);
2034 goto err_probe;
2035 }
2036 if (!mtd) {
2037 if (floor == 0)
2038 goto notfound;
2039 else
2040 continue;
2041 }
2040 docg3_floors[floor] = mtd; 2042 docg3_floors[floor] = mtd;
2043 ret = mtd_device_parse_register(mtd, part_probes, NULL, NULL,
2044 0);
2041 if (ret) 2045 if (ret)
2042 goto err_probe; 2046 goto err_probe;
2043 if (mtd) 2047 found++;
2044 found++;
2045 } 2048 }
2046 2049
2047 ret = doc_register_sysfs(pdev, docg3_floors); 2050 ret = doc_register_sysfs(pdev, docg3_floors);