On Tue, 2015-06-09 at 14:25 -0700, Andrew Morton wrote: > On Tue, 9 Jun 2015 21:04:48 +0900 Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx> wrote: > > > The existing pools' destroy() functions do not allow NULL pool pointers; > > instead, every destructor() caller forced to check if pool is not NULL, > > which: > > a) requires additional attention from developers/reviewers > > b) may lead to a NULL pointer dereferences if (a) didn't work > > > > > > First 3 patches tweak > > - kmem_cache_destroy() > > - mempool_destroy() > > - dma_pool_destroy() > > > > to handle NULL pointers. > > Well I like it, even though it's going to cause a zillion little cleanup > patches. > > checkpatch already has a "kfree(NULL) is safe and this check is > probably not required" test so I guess Joe will need to get busy ;) Maybe it'll be Julia's crew. The checkpatch change is pretty trivial --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 69c4716..3d6e34d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4801,7 +4801,7 @@ sub process { # check for needless "if (<foo>) fn(<foo>)" uses if ($prevline =~ /\bif\s*\(\s*($Lval)\s*\)/) { my $expr = '\s*\(\s*' . quotemeta($1) . '\s*\)\s*;'; - if ($line =~ /\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?)$expr/) { + if ($line =~ /\b(kfree|usb_free_urb|debugfs_remove(?:_recursive)?|(?:kmem_cache|mempool|dma_pool)_destroy)$expr/) { WARN('NEEDLESS_IF', "$1(NULL) is safe and this check is probably not required\n" . $hereprev); } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>