Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: maps: add missing iounmap() in error path

This patch was triggered by the following Coccinelle error:

./drivers/mtd/maps/sc520cdp.c:246:3-9: \
ERROR: missing iounmap; ioremap on line 242 \
and execution via conditional on line 244

Since do_map_probe() is also invoked in this loop, it is also necessary to
map_destroy() any initialised struct mtd_info.

Signed-off-by: Luis Henriques <henrix@camandro.org>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>

authored by

Luis Henriques and committed by
Brian Norris
3502fbcc 5fed67df

+7 -1
+7 -1
drivers/mtd/maps/sc520cdp.c
··· 227 227 228 228 static int __init init_sc520cdp(void) 229 229 { 230 - int i, devices_found = 0; 230 + int i, j, devices_found = 0; 231 231 232 232 #ifdef REPROGRAM_PAR 233 233 /* reprogram PAR registers so flash appears at the desired addresses */ ··· 243 243 244 244 if (!sc520cdp_map[i].virt) { 245 245 printk("Failed to ioremap_nocache\n"); 246 + for (j = 0; j < i; j++) { 247 + if (mymtd[j]) { 248 + map_destroy(mymtd[j]); 249 + iounmap(sc520cdp_map[j].virt); 250 + } 251 + } 246 252 return -EIO; 247 253 } 248 254