Re: [PATCH 8/9] bcache: initiate bcache_debug to NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2018-07-26 at 22:22 +-0800, Coly Li wrote:
+AD4- Global variable bcache+AF8-debug is firstly initialized in bch+AF8-debug+AF8-init(),
+AD4- and destroyed in bch+AF8-debug+AF8-exit(). bch+AF8-debug+AF8-init() is called in
+AD4- bcache+AF8-init() with many other functions, if one of the previous calling
+AD4- onces failed, bcache+AF8-exit() will be called in the failure path.
+AD4- 
+AD4- The problem is, if bcache+AF8-init() fails before bch+AF8-debug+AF8-init() is called,
+AD4- then in bcache+AF8-exit() when bch+AF8-debug+AF8-exit() is called to destroy global
+AD4- variable bcache+AF8-debug, at this moment bcache+AF8-debug is unndefined, then the
+AD4- test of +ACI-if (+ACE-IS+AF8-ERR+AF8-OR+AF8-NULL(bcache+AF8-debug))+ACI- might be buggy.
+AD4- 
+AD4- This patch initializes global varabile bcache+AF8-debug to be NULL, to make
+AD4- the failure code path to be predictable.
+AD4- 
+AD4- Signed-off-by: Coly Li +ADw-colyli+AEA-suse.de+AD4-
+AD4- ---
+AD4-  drivers/md/bcache/debug.c +AHw- 2 +--
+AD4-  1 file changed, 1 insertion(+-), 1 deletion(-)
+AD4- 
+AD4- diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
+AD4- index 57f8f5aeee55..24b0eb65ddec 100644
+AD4- --- a/drivers/md/bcache/debug.c
+AD4- +-+-+- b/drivers/md/bcache/debug.c
+AD4- +AEAAQA- -17,7 +-17,7 +AEAAQA-
+AD4-  +ACM-include +ADw-linux/random.h+AD4-
+AD4-  +ACM-include +ADw-linux/seq+AF8-file.h+AD4-
+AD4-  
+AD4- -struct dentry +ACo-bcache+AF8-debug+ADs-
+AD4- +-struct dentry +ACo-bcache+AF8-debug +AD0- NULL+ADs-
+AD4-  
+AD4-  +ACM-ifdef CONFIG+AF8-BCACHE+AF8-DEBUG

Please verify patches with checkpatch before posting these. Checkpatch is namely
able to detect that this patch is useless:

+ACQ- scripts/checkpatch.pl +AFwAWw-PATCH+AF8-8+AF8-9+AFwAXQBf-bcache+AFw-:+AF8-initiate+AF8-bcache+AF8-debug+AF8-to+AF8-NULL.mbox 
ERROR: do not initialise globals to NULL
+ACM-217: FILE: drivers/md/bcache/debug.c:20:
+-struct dentry +ACo-bcache+AF8-debug +AD0- NULL+ADs-

Bart.

--
To unsubscribe from this list: send the line "unsubscribe linux-bcache" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux