Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751782AbdITQ6t (ORCPT ); Wed, 20 Sep 2017 12:58:49 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:33496 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751741AbdITQ6n (ORCPT ); Wed, 20 Sep 2017 12:58:43 -0400 X-Google-Smtp-Source: AOwi7QATg3PNyjYYaXIb29i7/EB1skT7yvRqLCtwjT4oXiIWwziKZmmSWJLNjdLw+K0FwZBrPFBGAg== Subject: Re: [PATCH] PM / OPP: Handle return value of kasprintf To: Viresh Kumar , Joe Perches References: <15cec6eac63ffc9f12f1d16aff913eccad670f77.1505817563.git.arvind.yadav.cs@gmail.com> <1505906255.2153.3.camel@perches.com> <20170920144902.GL30848@ubuntu> Cc: vireshk@kernel.org, nm@ti.com, sboyd@codeaurora.org, rjw@rjwysocki.net, pavel@ucw.cz, len.brown@intel.com, gregkh@linuxfoundation.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org From: arvind Message-ID: <59C29E3C.5010703@gmail.com> Date: Wed, 20 Sep 2017 22:28:36 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20170920144902.GL30848@ubuntu> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 850 Lines: 28 Hi, On Wednesday 20 September 2017 08:19 PM, Viresh Kumar wrote: > On 20-09-17, 04:17, Joe Perches wrote: >> 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 > Sure. > > @Arvind: I will let you write that patch. Yes, I will do. > ~arvind