From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752608AbbFQEmw (ORCPT ); Wed, 17 Jun 2015 00:42:52 -0400 Received: from smtprelay0246.hostedemail.com ([216.40.44.246]:39000 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750899AbbFQEmo (ORCPT ); Wed, 17 Jun 2015 00:42:44 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:2899:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:5007:6261:7974:10004:10400:10848:11026:11232:11658:11914:12296:12517:12519:12740:13069: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: test90_17a63b4538e3d X-Filterd-Recvd-Size: 2077 Message-ID: <1434516161.2689.67.camel@perches.com> Subject: Re: [PATCH 2/6] mtd: nandsim: Fix kasprintf() usage From: Joe Perches To: Brian Norris Cc: Richard Weinberger , dwmw2@infradead.org, maximlevitsky@gmail.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Date: Tue, 16 Jun 2015 21:42:41 -0700 In-Reply-To: <20150617020707.GD4917@ld-irv-0074> References: <1433193054-26865-1-git-send-email-richard@nod.at> <1433193054-26865-3-git-send-email-richard@nod.at> <20150617020707.GD4917@ld-irv-0074> 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 On Tue, 2015-06-16 at 19:07 -0700, Brian Norris wrote: > On Mon, Jun 01, 2015 at 11:10:50PM +0200, Richard Weinberger wrote: > > kasprintf() used in get_partition_name() does a dynamic > > memory allocation and can fail. We have to handle that case. [] > > diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c [] > > @@ -743,6 +743,11 @@ static int init_nandsim(struct mtd_info *mtd) > > goto error; > > } > > ns->partitions[i].name = get_partition_name(i); > > + if (!ns->partitions[i].name) { > > + NS_ERR("unable to allocate memory.\n"); > > Probably don't really need the allocation failure messages. But this > matches the current style, so we can just rip the messages out at > another time. Maybe that other time can use the more typical pr_ mechanisms instead of NS_ too. As far as I can tell, the only thing that the NS_ macros do is prefix "error: " and "warning: " to the output. "[nandsim] " could be added via pr_fmt and it could be changed to "nandsim: " for commonality with the majority of the kernel logging.