Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751897AbdITLRk (ORCPT ); Wed, 20 Sep 2017 07:17:40 -0400 Received: from smtprelay0172.hostedemail.com ([216.40.44.172]:46909 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751848AbdITLRj (ORCPT ); Wed, 20 Sep 2017 07:17:39 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::,RULES_HIT:41:355:379:541:599:960:966:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1539:1593:1594:1711:1714:1730:1747:1777:1792:2196:2198:2199:2200:2393:2559:2562:2828:3138:3139:3140:3141:3142:3350:3622:3865:3867:3868:4321:4385:5007:7901:10004:10400:10848:11026:11657:11658:11914:12043:12048:12438:12740:12760:12895:13069:13311:13357:13439:14659:14721:21080:21627:30029:30054:30070:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: stew08_255bd6d90d131 X-Filterd-Recvd-Size: 1595 Message-ID: <1505906255.2153.3.camel@perches.com> Subject: Re: [PATCH] PM / OPP: Handle return value of kasprintf From: Joe Perches To: Arvind Yadav , vireshk@kernel.org, nm@ti.com, sboyd@codeaurora.org, rjw@rjwysocki.net, pavel@ucw.cz, len.brown@intel.com, gregkh@linuxfoundation.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 20 Sep 2017 04:17:35 -0700 In-Reply-To: <15cec6eac63ffc9f12f1d16aff913eccad670f77.1505817563.git.arvind.yadav.cs@gmail.com> References: <15cec6eac63ffc9f12f1d16aff913eccad670f77.1505817563.git.arvind.yadav.cs@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 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: 616 Lines: 19 On Wed, 2017-09-20 at 12:29 +0530, Arvind Yadav wrote: > kasprintf() can fail here and we must check its return value. [] > diff --git a/drivers/base/power/opp/debugfs.c b/drivers/base/power/opp/debugfs.c [] > @@ -45,7 +45,8 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp, > > for (i = 0; i < opp_table->regulator_count; i++) { > name = kasprintf(GFP_KERNEL, "supply-%d", i); > - > + if (!name) > + return false; > /* Create per-opp directory */ > d = debugfs_create_dir(name, pdentry); Probably more sensible to avoid the kasprintf/kfree and just have char name[20]; on the stack