From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752987AbcLJUyz (ORCPT ); Sat, 10 Dec 2016 15:54:55 -0500 Received: from smtprelay0007.hostedemail.com ([216.40.44.7]:37360 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752131AbcLJUyy (ORCPT ); Sat, 10 Dec 2016 15:54:54 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3355:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:5007:6117:6119:7875:7903:9010:10004:10400:10848:11026:11232:11473:11658:11914:12043:12679:12740:12760:13439:14181:14659:14721:21080:21324:30003:30036:30054:30064:30075:30090:30091,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,LFtime:2,LUA_SUMMARY:none X-HE-Tag: bat57_2a789d56b3536 X-Filterd-Recvd-Size: 3878 Message-ID: <1481403290.1764.1.camel@perches.com> Subject: Re: [patch] nvme-fabrics: correct some printk information From: Joe Perches To: Julia Lawall , Dan Carpenter Cc: James Smart , Keith Busch , Jens Axboe , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Date: Sat, 10 Dec 2016 12:54:50 -0800 In-Reply-To: References: <20161210090618.GA11680@elgon.mountain> <1481369270.5946.51.camel@perches.com> <20161210184029.GY8176@mwanda> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.1-0ubuntu2 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 On Sat, 2016-12-10 at 21:06 +0100, Julia Lawall wrote: > > On Sat, 10 Dec 2016, Dan Carpenter wrote: > > > On Sat, Dec 10, 2016 at 03:27:50AM -0800, Joe Perches wrote: > > > On Sat, 2016-12-10 at 12:06 +0300, Dan Carpenter wrote: > > > > We really don't care where "ctrl" is on the stack since we're just > > > > returning soon what we want is the actual ctrl pointer itself. > > > > > > > > Signed-off-by: Dan Carpenter > > > > > > > > diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c > > > > > > [] > > > > @@ -2402,7 +2402,7 @@ enum blk_eh_timer_return > > > > > > > > dev_info(ctrl->ctrl.device, > > > > "NVME-FC{%d}: new ctrl: NQN \"%s\" (%p)\n", > > > > - ctrl->cnum, ctrl->ctrl.opts->subsysnqn, &ctrl); > > > > + ctrl->cnum, ctrl->ctrl.opts->subsysnqn, ctrl); > > > > > > Found by script or inspection? > > > > > > If by script, it seems unlikely there's only 1 instance > > > where an address of an automatic pointer type is used > > > incorrectly. > > > > Script. But it's using a pretty specific heuristic where we kmalloc a > > pointer and then pass the address. It prints few warnings. Probably > > 40% false positives, but the remaining examples of course are 100% false > > positives. > > I tried anything that looks like a print, ie has a format string argument, > and was taking the address of a local variable as another argument. But > there are lots of weird format designators in the kernel that Coccinelle > doesn't know about for which passing the address of a local variable is > reasonable. So for the moment, there are, as far as I can see, just a lot > of false positives. I did add improving the support for format strings to > my TODO list. I think there's probably a class of defects that could be found something like this in coccinelle: @@ type T; T *t; @@ * \(netdev_emerg\|netdev_crit\|netdev_alert\|netdev_err\|netdev_notice\|netdev_warn\|netdev_warn\|netdev_info\|netdev_dbg\|dev_emerg\|dev_crit\|dev_alert\|dev_err\|dev_notice\|dev_warn\|dev_warn\|dev_info\|dev_dbg\|pr_emerg\|pr_crit\|pr_alert\|pr_err\|pr_notice\|pr_warn\|pr_warning\|pr_warn\|pr_info\|pr_debug\|printk\|vsprintf\|vscnprintf\|vsprintf\)(..., &t, ...); This finds a few like: diff -u -p drivers//dma/pxa_dma.c /tmp/nothing//dma/pxa_dma.c --- drivers//dma/pxa_dma.c +++ /tmp/nothing//dma/pxa_dma.c @@ -640,9 +640,6 @@ static unsigned int clear_chan_irq(struc dcsr = phy_readl_relaxed(phy, DCSR); phy_writel(phy, dcsr, DCSR); if ((dcsr & PXA_DCSR_BUSERR) && (phy->vchan)) - dev_warn(&phy->vchan->vc.chan.dev->device, - "%s(chan=%p): PXA_DCSR_BUSERR\n", - __func__, &phy->vchan); return dcsr & ~PXA_DCSR_RUN; } btw: It'd be nice if coccinelle could use multiple nested "\("