2012-10-03 08:25:44

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: UBI: Fastmap request for inclusion (v19)

On Wed, 2012-09-26 at 17:51 +0200, Richard Weinberger wrote:
> UBI Fastmap is an optional feature which stores the physical to
> logical eraseblock relations in a checkpoint (called fastmap) to reduce
> the initialization time of UBI. The current init time of UBI is
> proportional to the number of physical erase blocks on the FLASH
> device. With fastmap enabled the scan time is limited to a fixed
> number of blocks.

Aiaiai complains and linux-next build fails :-( Last time I forgot to
enable the fastmap kbuild option so aiaiai checked with that option
disabled. Now I enabled it with a simple hack (default n -> default y)
and here are aiaiai's complaints - there is a build failure for
ARCH=i386.

I should improve aiaiai to automatically enable new Kconfig features, or
at least warn about them. This is not the first time someone sends a new
driver which is default off, and I forget to enable it :-(


dedekind@blue:~/git/maintaining$ ../aiaiai/aiaiai-concat-mboxes ../linux-ubi/00* | ./verify ../linux-ubi gen -c 55393ba1bdedc5ded79b34b4cc08898a7776cddb
Tested the patch(es) on top of the following commits:
e4e9957 Quick fixes - applied by aiaiai
55393ba UBI: fix trivial typo 'it' => 'is'
cf38aca UBI: load after mtd device drivers
719bb84 UBI: print less

--------------------------------------------------------------------------------

Successfully built configuration "arm-omap2plus_defconfig,arm,arm-unknown-linux-gnueabi-", results:

--- before_patching.log
+++ after_patching.log
@@ @@
+drivers/mtd/ubi/fastmap.c:1012 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1012:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1017:7-11: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1027 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1027:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1033 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1033:1-3: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1077 ubi_scan_fastmap() warn: possible memory leak of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1479 ubi_update_fastmap() error: we previously assumed 'tmp_e' could be null (see line 1463) [smatch]
+drivers/mtd/ubi/fastmap.c:925 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:925:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:926 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:926:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:933 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:933:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:934 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:934:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:940 ubi_scan_fastmap() error: dereferencing freed memory 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:940:21-25: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:944 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:944:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:956 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:956:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:959 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:959:3-5: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:967 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:967:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:976 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:976:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:988 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:988:10-12: ERROR: reference preceded by free on line 919 [coccinelle]
@@ @@
+drivers/mtd/ubi/wl.c:284:3-9: preceding lock on line 282 [coccinelle]

--------------------------------------------------------------------------------
Failed to build the following commit for configuration "i386_defconfig" (architecture i386)":

88f4a02 UBI: Wire-up fastmap

drivers/mtd/nand/r852.c:571:6: warning: no previous prototype for ‘r852_engine_disable’ [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:581:6: warning: no previous prototype for ‘r852_card_update_present’ [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:596:6: warning: no previous prototype for ‘r852_update_card_detect’ [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:610:9: warning: no previous prototype for ‘r852_media_type_show’ [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:625:6: warning: no previous prototype for ‘r852_update_media_status’ [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:654:5: warning: no previous prototype for ‘r852_register_nand_device’ [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:692:6: warning: no previous prototype for ‘r852_unregister_nand_device’ [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:706:6: warning: no previous prototype for ‘r852_card_detect_work’ [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:845:6: warning: no previous prototype for ‘r852_probe’ [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:986:6: warning: no previous prototype for ‘r852_remove’ [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:1017:6: warning: no previous prototype for ‘r852_shutdown’ [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:44:9: warning: no previous prototype for ‘sm_attr_show’ [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:57:25: warning: no previous prototype for ‘sm_create_sysfs_attributes’ [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:110:6: warning: no previous prototype for ‘sm_delete_sysfs_attributes’ [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:575:5: warning: no previous prototype for ‘sm_get_media_info’ [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:882:18: warning: no previous prototype for ‘sm_get_zone’ [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:903:6: warning: no previous prototype for ‘sm_cache_init’ [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:913:6: warning: no previous prototype for ‘sm_cache_put’ [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:921:5: warning: no previous prototype for ‘sm_cache_get’ [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:932:5: warning: no previous prototype for ‘sm_cache_flush’ [-Wmissing-prototypes]
ERROR: "ubi_update_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
ERROR: "ubi_scan_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
ERROR: "ubi_calc_fm_size" [drivers/mtd/ubi/ubi.ko] undefined!
make[2]: *** [__modpost] Error 1

--------------------------------------------------------------------------------
Failed to build the following commit for configuration "ia64_defconfig" (architecture ia64)":

88f4a02 UBI: Wire-up fastmap

drivers/mtd/nand/r852.c:381:5: warning: no previous prototype for 'r852_wait' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:410:5: warning: no previous prototype for 'r852_ready' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:421:6: warning: no previous prototype for 'r852_ecc_hwctl' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:453:5: warning: no previous prototype for 'r852_ecc_calculate' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:485:5: warning: no previous prototype for 'r852_ecc_correct' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:553:6: warning: no previous prototype for 'r852_engine_enable' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:571:6: warning: no previous prototype for 'r852_engine_disable' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:581:6: warning: no previous prototype for 'r852_card_update_present' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:596:6: warning: no previous prototype for 'r852_update_card_detect' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:610:9: warning: no previous prototype for 'r852_media_type_show' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:625:6: warning: no previous prototype for 'r852_update_media_status' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:654:5: warning: no previous prototype for 'r852_register_nand_device' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:692:6: warning: no previous prototype for 'r852_unregister_nand_device' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:706:6: warning: no previous prototype for 'r852_card_detect_work' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:845:6: warning: no previous prototype for 'r852_probe' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:986:6: warning: no previous prototype for 'r852_remove' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:1017:6: warning: no previous prototype for 'r852_shutdown' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:1028:12: warning: 'r852_suspend' defined but not used [-Wunused-function]
drivers/mtd/nand/r852.c:1049:12: warning: 'r852_resume' defined but not used [-Wunused-function]
WARNING: modpost: Found 1 section mismatch(es).
ERROR: "ubi_update_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
ERROR: "ubi_scan_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
ERROR: "ubi_calc_fm_size" [drivers/mtd/ubi/ubi.ko] undefined!
make[2]: *** [__modpost] Error 1

--------------------------------------------------------------------------------

Successfully built configuration "m68k-m5208evb_defconfig,m68k,m68k-linux-", results:

--- before_patching.log
+++ after_patching.log
@@ @@
+drivers/mtd/ubi/fastmap.c:1012 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1012:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1017:7-11: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1027 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1027:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1033 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1033:1-3: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1077 ubi_scan_fastmap() warn: possible memory leak of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1479 ubi_update_fastmap() error: we previously assumed 'tmp_e' could be null (see line 1463) [smatch]
+drivers/mtd/ubi/fastmap.c:925 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:925:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:926 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:926:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:933 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:933:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:934 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:934:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:940 ubi_scan_fastmap() error: dereferencing freed memory 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:940:21-25: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:944 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:944:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:956 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:956:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:959 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:959:3-5: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:967 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:967:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:976 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:976:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:988 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:988:10-12: ERROR: reference preceded by free on line 919 [coccinelle]
@@ @@
+drivers/mtd/ubi/wl.c:284:3-9: preceding lock on line 282 [coccinelle]

--------------------------------------------------------------------------------
Failed to build the following commit for configuration "mips64_defconfig" (architecture mips)":

88f4a02 UBI: Wire-up fastmap

drivers/mtd/nand/r852.c:571:6: warning: no previous prototype for 'r852_engine_disable' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:581:6: warning: no previous prototype for 'r852_card_update_present' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:596:6: warning: no previous prototype for 'r852_update_card_detect' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:610:9: warning: no previous prototype for 'r852_media_type_show' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:625:6: warning: no previous prototype for 'r852_update_media_status' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:654:5: warning: no previous prototype for 'r852_register_nand_device' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:692:6: warning: no previous prototype for 'r852_unregister_nand_device' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:706:6: warning: no previous prototype for 'r852_card_detect_work' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:845:6: warning: no previous prototype for 'r852_probe' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:986:6: warning: no previous prototype for 'r852_remove' [-Wmissing-prototypes]
drivers/mtd/nand/r852.c:1017:6: warning: no previous prototype for 'r852_shutdown' [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:44:9: warning: no previous prototype for 'sm_attr_show' [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:57:25: warning: no previous prototype for 'sm_create_sysfs_attributes' [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:110:6: warning: no previous prototype for 'sm_delete_sysfs_attributes' [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:575:5: warning: no previous prototype for 'sm_get_media_info' [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:882:18: warning: no previous prototype for 'sm_get_zone' [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:903:6: warning: no previous prototype for 'sm_cache_init' [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:913:6: warning: no previous prototype for 'sm_cache_put' [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:921:5: warning: no previous prototype for 'sm_cache_get' [-Wmissing-prototypes]
drivers/mtd/sm_ftl.c:932:5: warning: no previous prototype for 'sm_cache_flush' [-Wmissing-prototypes]
ERROR: "ubi_update_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
ERROR: "ubi_scan_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
ERROR: "ubi_calc_fm_size" [drivers/mtd/ubi/ubi.ko] undefined!
make[2]: *** [__modpost] Error 1

--------------------------------------------------------------------------------

Successfully built configuration "mips-bcm63xx_defconfig,mips,mips-linux-", results:

--- before_patching.log
+++ after_patching.log
@@ @@
+drivers/mtd/ubi/fastmap.c:1012 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1012:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1017:7-11: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1027 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1027:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1033 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1033:1-3: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1077 ubi_scan_fastmap() warn: possible memory leak of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1479 ubi_update_fastmap() error: we previously assumed 'tmp_e' could be null (see line 1463) [smatch]
+drivers/mtd/ubi/fastmap.c:925 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:925:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:926 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:926:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:933 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:933:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:934 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:934:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:940 ubi_scan_fastmap() error: dereferencing freed memory 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:940:21-25: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:944 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:944:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:956 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:956:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:959 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:959:3-5: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:967 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:967:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:976 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:976:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:988 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:988:10-12: ERROR: reference preceded by free on line 919 [coccinelle]
@@ @@
+drivers/mtd/ubi/wl.c:284:3-9: preceding lock on line 282 [coccinelle]

--------------------------------------------------------------------------------

Successfully built configuration "ppc32_defconfig,powerpc,powerpc-linux-", results:

--- before_patching.log
+++ after_patching.log
@@ @@
+drivers/mtd/ubi/fastmap.c:1012 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1012:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1017:7-11: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1027 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1027:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1033 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1033:1-3: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1077 ubi_scan_fastmap() warn: possible memory leak of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1479 ubi_update_fastmap() error: we previously assumed 'tmp_e' could be null (see line 1463) [smatch]
+drivers/mtd/ubi/fastmap.c:925 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:925:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:926 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:926:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:933 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:933:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:934 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:934:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:940 ubi_scan_fastmap() error: dereferencing freed memory 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:940:21-25: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:944 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:944:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:956 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:956:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:959 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:959:3-5: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:967 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:967:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:976 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:976:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:988 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:988:10-12: ERROR: reference preceded by free on line 919 [coccinelle]
@@ @@
+drivers/mtd/ubi/wl.c:284:3-9: preceding lock on line 282 [coccinelle]

--------------------------------------------------------------------------------

Successfully built configuration "ppc64_defconfig,powerpc,powerpc64-linux-", results:

--- before_patching.log
+++ after_patching.log
@@ @@
+drivers/mtd/ubi/fastmap.c:1012 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1012:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1017:7-11: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1027 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1027:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1033 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1033:1-3: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1077 ubi_scan_fastmap() warn: possible memory leak of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1479 ubi_update_fastmap() error: we previously assumed 'tmp_e' could be null (see line 1463) [smatch]
+drivers/mtd/ubi/fastmap.c:925 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:925:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:926 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:926:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:933 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:933:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:934 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:934:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:940 ubi_scan_fastmap() error: dereferencing freed memory 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:940:21-25: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:944 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:944:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:956 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:956:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:959 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:959:3-5: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:967 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:967:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:976 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:976:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:988 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:988:10-12: ERROR: reference preceded by free on line 919 [coccinelle]
@@ @@
+drivers/mtd/ubi/wl.c:284:3-9: preceding lock on line 282 [coccinelle]

--------------------------------------------------------------------------------

Successfully built configuration "x86_64_defconfig,x86_64,", results:

--- before_patching.log
+++ after_patching.log
@@ @@
+drivers/mtd/ubi/fastmap.c:1012 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1012:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1017:7-11: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1027 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1027:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1033 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1033:1-3: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:1077 ubi_scan_fastmap() warn: possible memory leak of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:1479 ubi_update_fastmap() error: we previously assumed 'tmp_e' could be null (see line 1463) [smatch]
+drivers/mtd/ubi/fastmap.c:925 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:925:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:926 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:926:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:933 ubi_scan_fastmap() error: double free of 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:933:8-12: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:934 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:934:8-10: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:940 ubi_scan_fastmap() error: dereferencing freed memory 'fmsb' [smatch]
+drivers/mtd/ubi/fastmap.c:940:21-25: ERROR: reference preceded by free on line 918 [coccinelle]
+drivers/mtd/ubi/fastmap.c:944 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:944:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:956 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:956:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:959 ubi_scan_fastmap() error: dereferencing freed memory 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:959:3-5: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:967 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:967:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:976 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:976:9-11: ERROR: reference preceded by free on line 919 [coccinelle]
+drivers/mtd/ubi/fastmap.c:988 ubi_scan_fastmap() error: double free of 'fm' [smatch]
+drivers/mtd/ubi/fastmap.c:988:10-12: ERROR: reference preceded by free on line 919 [coccinelle]
@@ @@
+drivers/mtd/ubi/wl.c:284:3-9: preceding lock on line 282 [coccinelle]

--------------------------------------------------------------------------------

checkpatch.pl has some complaints:

--------------------------------------------------------------------------------

checkpatch.pl results for patch "[PATCH 07/10] UBI: Add fastmap stuff to attach.c"

WARNING:LONG_LINE: line over 80 characters
#115: FILE: drivers/mtd/ubi/attach.c:1008:
+ ubi_msg("\"delete\" compatible internal volume %d:%d found, will remove it",

total: 0 errors, 1 warnings, 550 lines checked

--------------------------------------------------------------------------------

checkpatch.pl results for the entire squashed patch-set

WARNING:LONG_LINE: line over 80 characters
#987: FILE: drivers/mtd/ubi/attach.c:1008:
+ ubi_msg("\"delete\" compatible internal volume %d:%d found, will remove it",

total: 0 errors, 1 warnings, 3708 lines checked

--------------------------------------------------------------------------------

--
Best Regards,
Artem Bityutskiy


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2012-10-03 08:36:35

by Richard Weinberger

[permalink] [raw]
Subject: Re: UBI: Fastmap request for inclusion (v19)

Am Wed, 03 Oct 2012 11:25:45 +0300
schrieb Artem Bityutskiy <[email protected]>:

> On Wed, 2012-09-26 at 17:51 +0200, Richard Weinberger wrote:
> > UBI Fastmap is an optional feature which stores the physical to
> > logical eraseblock relations in a checkpoint (called fastmap) to
> > reduce the initialization time of UBI. The current init time of UBI
> > is proportional to the number of physical erase blocks on the FLASH
> > device. With fastmap enabled the scan time is limited to a fixed
> > number of blocks.
>
> Aiaiai complains and linux-next build fails :-( Last time I forgot to
> enable the fastmap kbuild option so aiaiai checked with that option
> disabled. Now I enabled it with a simple hack (default n -> default y)
> and here are aiaiai's complaints - there is a build failure for
> ARCH=i386.

Build fix for linux-next is on the way into your inbox.
I'm currently looking at the aiaiai output.

Thanks,
//richard

2012-10-03 08:43:11

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: UBI: Fastmap request for inclusion (v19)

On Wed, 2012-10-03 at 10:36 +0200, Richard Weinberger wrote:
> Am Wed, 03 Oct 2012 11:25:45 +0300
> schrieb Artem Bityutskiy <[email protected]>:
>
> > On Wed, 2012-09-26 at 17:51 +0200, Richard Weinberger wrote:
> > > UBI Fastmap is an optional feature which stores the physical to
> > > logical eraseblock relations in a checkpoint (called fastmap) to
> > > reduce the initialization time of UBI. The current init time of UBI
> > > is proportional to the number of physical erase blocks on the FLASH
> > > device. With fastmap enabled the scan time is limited to a fixed
> > > number of blocks.
> >
> > Aiaiai complains and linux-next build fails :-( Last time I forgot to
> > enable the fastmap kbuild option so aiaiai checked with that option
> > disabled. Now I enabled it with a simple hack (default n -> default y)
> > and here are aiaiai's complaints - there is a build failure for
> > ARCH=i386.
>
> Build fix for linux-next is on the way into your inbox.
> I'm currently looking at the aiaiai output.

I've taken a quick look - you call 'kfree(fm)' 16 times in that
function. Even if we get everything correctly, we should probably change
that anyway with goto's.

--
Best Regards,
Artem Bityutskiy


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2012-10-03 08:44:42

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: UBI: Fastmap request for inclusion (v19)

On Wed, 2012-10-03 at 10:36 +0200, Richard Weinberger wrote:
> Am Wed, 03 Oct 2012 11:25:45 +0300
> schrieb Artem Bityutskiy <[email protected]>:
>
> > On Wed, 2012-09-26 at 17:51 +0200, Richard Weinberger wrote:
> > > UBI Fastmap is an optional feature which stores the physical to
> > > logical eraseblock relations in a checkpoint (called fastmap) to
> > > reduce the initialization time of UBI. The current init time of UBI
> > > is proportional to the number of physical erase blocks on the FLASH
> > > device. With fastmap enabled the scan time is limited to a fixed
> > > number of blocks.
> >
> > Aiaiai complains and linux-next build fails :-( Last time I forgot to
> > enable the fastmap kbuild option so aiaiai checked with that option
> > disabled. Now I enabled it with a simple hack (default n -> default y)
> > and here are aiaiai's complaints - there is a build failure for
> > ARCH=i386.
>
> Build fix for linux-next is on the way into your inbox.
> I'm currently looking at the aiaiai output.

OK, I see, goto out is missing after line 919. Please, send a short fix
- I'll squash it in. But general error-path rework is needed for this
function, may be separately.

--
Best Regards,
Artem Bityutskiy


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2012-10-03 09:03:26

by Richard Weinberger

[permalink] [raw]
Subject: Re: UBI: Fastmap request for inclusion (v19)

On 03.10.2012 10:44, Artem Bityutskiy wrote:
> On Wed, 2012-10-03 at 10:36 +0200, Richard Weinberger wrote:
>> Am Wed, 03 Oct 2012 11:25:45 +0300
>> schrieb Artem Bityutskiy <[email protected]>:
>>
>>> On Wed, 2012-09-26 at 17:51 +0200, Richard Weinberger wrote:
>>>> UBI Fastmap is an optional feature which stores the physical to
>>>> logical eraseblock relations in a checkpoint (called fastmap) to
>>>> reduce the initialization time of UBI. The current init time of UBI
>>>> is proportional to the number of physical erase blocks on the FLASH
>>>> device. With fastmap enabled the scan time is limited to a fixed
>>>> number of blocks.
>>>
>>> Aiaiai complains and linux-next build fails :-( Last time I forgot to
>>> enable the fastmap kbuild option so aiaiai checked with that option
>>> disabled. Now I enabled it with a simple hack (default n -> default y)
>>> and here are aiaiai's complaints - there is a build failure for
>>> ARCH=i386.
>>
>> Build fix for linux-next is on the way into your inbox.
>> I'm currently looking at the aiaiai output.
>
> OK, I see, goto out is missing after line 919. Please, send a short fix
> - I'll squash it in. But general error-path rework is needed for this
> function, may be separately.
>

Yeah, it looks like all issues reported by aiaiai are caused by the missing goto.
Can you deal with the patch below or do you want me to send it using git send-email?

Thanks,
//richard

---
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index be73a1d..adcb2e4 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -917,6 +917,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
ret = UBI_BAD_FASTMAP;
kfree(fmsb);
kfree(fm);
+ goto out;
}

ech = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);

2012-10-03 09:30:53

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: UBI: Fastmap request for inclusion (v19)

On Wed, 2012-10-03 at 11:03 +0200, Richard Weinberger wrote:
> Yeah, it looks like all issues reported by aiaiai are caused by the missing goto.
> Can you deal with the patch below or do you want me to send it using git send-email?

I'll apply it. But please, re-work the error handling in that function
separately.

--
Best Regards,
Artem Bityutskiy


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2012-10-03 09:32:34

by Richard Weinberger

[permalink] [raw]
Subject: Re: UBI: Fastmap request for inclusion (v19)

On 03.10.2012 11:30, Artem Bityutskiy wrote:
> On Wed, 2012-10-03 at 11:03 +0200, Richard Weinberger wrote:
>> Yeah, it looks like all issues reported by aiaiai are caused by the missing goto.
>> Can you deal with the patch below or do you want me to send it using git send-email?
>
> I'll apply it. But please, re-work the error handling in that function
> separately.
>

Okay, but not now during the merge window.
Is this fine for you?

Thanks,
//richard

2012-10-03 11:04:56

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: UBI: Fastmap request for inclusion (v19)

On Wed, 2012-10-03 at 10:36 +0200, Richard Weinberger wrote:
> Am Wed, 03 Oct 2012 11:25:45 +0300
> schrieb Artem Bityutskiy <[email protected]>:
>
> > On Wed, 2012-09-26 at 17:51 +0200, Richard Weinberger wrote:
> > > UBI Fastmap is an optional feature which stores the physical to
> > > logical eraseblock relations in a checkpoint (called fastmap) to
> > > reduce the initialization time of UBI. The current init time of UBI
> > > is proportional to the number of physical erase blocks on the FLASH
> > > device. With fastmap enabled the scan time is limited to a fixed
> > > number of blocks.
> >
> > Aiaiai complains and linux-next build fails :-( Last time I forgot to
> > enable the fastmap kbuild option so aiaiai checked with that option
> > disabled. Now I enabled it with a simple hack (default n -> default y)
> > and here are aiaiai's complaints - there is a build failure for
> > ARCH=i386.
>
> Build fix for linux-next is on the way into your inbox.
> I'm currently looking at the aiaiai output.

It did not help. I still get:

ERROR: "ubi_update_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
ERROR: "ubi_scan_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
ERROR: "ubi_calc_fm_size" [drivers/mtd/ubi/ubi.ko] undefined!

Please, see branch 'linux-next' in UBI to see what I actually tested.

--
Best Regards,
Artem Bityutskiy


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2012-10-03 11:18:46

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: UBI: Fastmap request for inclusion (v19)

On Wed, 2012-10-03 at 14:05 +0300, Artem Bityutskiy wrote:
> On Wed, 2012-10-03 at 10:36 +0200, Richard Weinberger wrote:
> > Am Wed, 03 Oct 2012 11:25:45 +0300
> > schrieb Artem Bityutskiy <[email protected]>:
> >
> > > On Wed, 2012-09-26 at 17:51 +0200, Richard Weinberger wrote:
> > > > UBI Fastmap is an optional feature which stores the physical to
> > > > logical eraseblock relations in a checkpoint (called fastmap) to
> > > > reduce the initialization time of UBI. The current init time of UBI
> > > > is proportional to the number of physical erase blocks on the FLASH
> > > > device. With fastmap enabled the scan time is limited to a fixed
> > > > number of blocks.
> > >
> > > Aiaiai complains and linux-next build fails :-( Last time I forgot to
> > > enable the fastmap kbuild option so aiaiai checked with that option
> > > disabled. Now I enabled it with a simple hack (default n -> default y)
> > > and here are aiaiai's complaints - there is a build failure for
> > > ARCH=i386.
> >
> > Build fix for linux-next is on the way into your inbox.
> > I'm currently looking at the aiaiai output.
>
> It did not help. I still get:
>
> ERROR: "ubi_update_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
> ERROR: "ubi_scan_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
> ERROR: "ubi_calc_fm_size" [drivers/mtd/ubi/ubi.ko] undefined!
>
> Please, see branch 'linux-next' in UBI to see what I actually tested.

And aiaiai has another correct complaint:

+drivers/mtd/ubi/fastmap.c:1078 ubi_scan_fastmap() warn: possible memory leak of 'fm' [smatch]

--
Best Regards,
Artem Bityutskiy


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part

2012-10-03 12:13:09

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: UBI: Fastmap request for inclusion (v19)

On Wed, 2012-10-03 at 14:05 +0300, Artem Bityutskiy wrote:
> ERROR: "ubi_update_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
> ERROR: "ubi_scan_fastmap" [drivers/mtd/ubi/ubi.ko] undefined!
> ERROR: "ubi_calc_fm_size" [drivers/mtd/ubi/ubi.ko] undefined!
>
> Please, see branch 'linux-next' in UBI to see what I actually tested.

Sorry, I did not apply your patch correctly, now it builds without
issues.

--
Best Regards,
Artem Bityutskiy


Attachments:
signature.asc (836.00 B)
This is a digitally signed message part