mtd: zero out mtd_partition struct before using it
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Tue Jan 12 15:59:05 PST 2016
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=938672338991ac8bef5cb025b187ab8d6230ac6c
Commit: 938672338991ac8bef5cb025b187ab8d6230ac6c
Parent: 215a02fd30871d0d888d27a3154588b66f5dbec2
Author: Brian Norris <computersforpeace at gmail.com>
AuthorDate: Wed Nov 11 16:47:52 2015 -0800
Committer: Brian Norris <computersforpeace at gmail.com>
CommitDate: Thu Nov 12 10:10:01 2015 -0800
mtd: zero out mtd_partition struct before using it
It's easier to guarantee we've cleared out all unused fields with
memset() than by manually initializing each field.
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon at free-electrons.com>
---
drivers/mtd/mtdpart.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index f8ba153..46dfbf5 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -596,11 +596,10 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
if (length <= 0)
return -EINVAL;
+ memset(&part, 0, sizeof(part));
part.name = name;
part.size = length;
part.offset = offset;
- part.mask_flags = 0;
- part.ecclayout = NULL;
new = allocate_partition(master, &part, -1, offset);
if (IS_ERR(new))
More information about the linux-mtd-cvs
mailing list