From d3fbd866576e393a0eef81ee890e72c6558c4dbf Mon Sep 17 00:00:00 2001 From: ziggurat29 Date: Wed, 27 Apr 2016 19:33:45 -0500 Subject: [PATCH] bug in smart.c; return code of smart_scan not checked, can cause success result in failure case, leading to 'dev' pointer being invalid. --- drivers/mtd/smart.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/smart.c b/drivers/mtd/smart.c index cb188c1854..50804cc3ab 100644 --- a/drivers/mtd/smart.c +++ b/drivers/mtd/smart.c @@ -5433,7 +5433,12 @@ int smart_initialize(int minor, FAR struct mtd_dev_s *mtd, FAR const char *partn /* Do a scan of the device */ - smart_scan(dev); + ret = smart_scan(dev); + if (ret < 0) + { + fdbg("smart_scan failed: %d\n", -ret); + goto errout; + } } #ifdef CONFIG_SMART_DEV_LOOP