lkml.org 
[lkml]   [2015]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [RFC][PATCH 0/5] do not dereference NULL pools in pools' destroy() functions
From
Date
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@gmail.com> 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);
}



\
 
 \ /
  Last update: 2015-06-10 02:21    [W:1.380 / U:0.616 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site