From b04c4972fe32c33e38ef60ac7fdc9b7bbbc2dda1 Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Tue, 19 Jul 2022 15:00:11 +0900 Subject: [PATCH] mtd/smartfs: Fix uninitialized variable If CONFIG_SMARTFS_MULTI_ROOT_DIRS is enabled and dev->partname is not empty, dev->rwbuffer is an uninitialized variable and register_blockdriver is called. --- drivers/mtd/smart.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/mtd/smart.c b/drivers/mtd/smart.c index 7fced45542a..2a8327803b2 100644 --- a/drivers/mtd/smart.c +++ b/drivers/mtd/smart.c @@ -2192,8 +2192,7 @@ static int smart_scan(FAR struct smart_struct_s *dev) { if (dev->partname[0] != '\0') { - snprintf(dev->rwbuffer, sizeof(devname), - "/dev/smart%d%sd%d", + snprintf(devname, sizeof(devname), "/dev/smart%d%sd%d", dev->minor, dev->partname, x + 1); } else @@ -2219,8 +2218,6 @@ static int smart_scan(FAR struct smart_struct_s *dev) rootdirdev->dev = dev; rootdirdev->rootdirnum = x; - ret = register_blockdriver(dev->rwbuffer, &g_bops, 0, - rootdirdev); /* Inode private data is a reference to the SMART device * structure.