Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754121AbbFJAGW (ORCPT ); Tue, 9 Jun 2015 20:06:22 -0400 Received: from smtprelay0143.hostedemail.com ([216.40.44.143]:55276 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752557AbbFJAGO (ORCPT ); Tue, 9 Jun 2015 20:06:14 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:966:968:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2196:2197:2199:2200:2201:2393:2553:2559:2562:2693:2828:2893:3138:3139:3140:3141:3142:3353:3622:3653:3865:3867:3868:3871:3872:4250:4321:4385:5007:6261:7514:7875:8531:10004:10400:10848:10967:11026:11232:11658:11914:12043:12517:12519:12555:12740:13069:13141:13161:13229:13230:13255:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: lace72_7029a12c33036 X-Filterd-Recvd-Size: 2928 Message-ID: <1433894769.2730.87.camel@perches.com> Subject: Re: [RFC][PATCH 0/5] do not dereference NULL pools in pools' destroy() functions From: Joe Perches To: Andrew Morton , Julia Lawall Cc: Sergey Senozhatsky , Minchan Kim , Christoph Lameter , Pekka Enberg , Joonsoo Kim , Michal Hocko , David Rientjes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, sergey.senozhatsky.work@gmail.com Date: Tue, 09 Jun 2015 17:06:09 -0700 In-Reply-To: <20150609142523.b717dba6033ee08de997c8be@linux-foundation.org> References: <1433851493-23685-1-git-send-email-sergey.senozhatsky@gmail.com> <20150609142523.b717dba6033ee08de997c8be@linux-foundation.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1876 Lines: 50 On Tue, 2015-06-09 at 14:25 -0700, Andrew Morton wrote: > On Tue, 9 Jun 2015 21:04:48 +0900 Sergey Senozhatsky 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 () fn()" 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/