From patchwork Thu Sep 21 05:45:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arvind Yadav X-Patchwork-Id: 9963273 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 022706020C for ; Thu, 21 Sep 2017 05:46:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E860E29327 for ; Thu, 21 Sep 2017 05:46:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DCC6229364; Thu, 21 Sep 2017 05:46:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84DE329327 for ; Thu, 21 Sep 2017 05:46:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751450AbdIUFqh (ORCPT ); Thu, 21 Sep 2017 01:46:37 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:37114 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751387AbdIUFqh (ORCPT ); Thu, 21 Sep 2017 01:46:37 -0400 Received: by mail-pg0-f67.google.com with SMTP id v5so2878959pgn.4; Wed, 20 Sep 2017 22:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=wnuCcGufUqGN2BxqJ124BGmlZ5+JA6hkszbI5lskvoQ=; b=YI1jvUIRldFdOcW9RMQclOHKl6e54KJfzJQ/wp4Cbx07KOO0ys1NLb78wuGHcMuPPG bytbY1XtTDv7Eb1vkaY3o5saNi1cFT5LQ6o3GR+W/q1G7BBJP5F4B1InvM6+7Xtn0LJR 4IZIsdqOWuaSFtcaOQS5Sc5NHqAX+qTv/Se96GB8dx1EDD6nXtQvZ/aly7WXwmgTiwC0 9uCubbWX9HjnsYDsta4l5XMf2KIcfpwJAetZ34QXsllAfQ6YzlDA8py6ORsEhJ3yW34k 7CX9JMGEvj8qYMptRVMRhb79aIYJ63oSDFERqx7FJQ7NNZ9jtHjuKoyrGe+jb34fnH+w 9A3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wnuCcGufUqGN2BxqJ124BGmlZ5+JA6hkszbI5lskvoQ=; b=NHuAE/PLRfodoAkPNliqfNvWHPlLJrIIICxZaKoALUXSw0RhKKrxQk2h+OTl371y15 mmzjDq24UIJ59Jrtcq9zoaYT/aog0G5ww8UqfD/l3OqjTBbml35/NwoxpLJmZwqSLtrW EWshR6RIjBf4ouaLcpPzM78Jgha0TZtdQBaGrTfHZDFxEVaAAzBhshYxEjYEcg9Hl5Zx MUaIFvKM7++4RNPTVJTqtXQoxGaX7+bWI4KGhh/1LSWyjNM3MTCYBghI4jJ5Z0XHjXSP SRM6OWRz2Jct2zU0TCWJmrL3CEYW47tHhodvDAyR0/U/2ym4TgzKM0A1CnH2EyPdzUDw MgBA== X-Gm-Message-State: AHPjjUioZSOVorNfklAvy9XnFGXZqaz5+loOz2e+blfpF4stK45qaYy3 yN2JAFnZOuJA456s1aP+th8= X-Google-Smtp-Source: AOwi7QAp/jYgzeMGl3kDgbrBhvkyOWcRcu8Q+LE7PiBIlgCAcYeI0dZm6bET8iXnxJBCmZDOECKOTQ== X-Received: by 10.98.77.70 with SMTP id a67mr4552077pfb.347.1505972796475; Wed, 20 Sep 2017 22:46:36 -0700 (PDT) Received: from symbol-HP-Z420-Workstation.zebra.lan ([223.31.70.102]) by smtp.googlemail.com with ESMTPSA id u74sm1034914pfk.125.2017.09.20.22.46.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 22:46:35 -0700 (PDT) From: Arvind Yadav To: 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 Subject: [PATCH v2] PM / OPP: Use snprintf to avoid kasprintf and kfree Date: Thu, 21 Sep 2017 11:15:36 +0530 Message-Id: <6cdcf0c59a9a045941188356a2c4973c876c9fc6.1505972576.git.arvind.yadav.cs@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use snprintf to avoid unnecessary initializations, avoid calling kfree. Signed-off-by: Arvind Yadav Acked-by: Viresh Kumar Reviewed-by: Stephen Boyd --- changes in v2: Remove kasprintf instead of error checking. drivers/base/power/opp/debugfs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/base/power/opp/debugfs.c b/drivers/base/power/opp/debugfs.c index 81cf120..a2fa785 100644 --- a/drivers/base/power/opp/debugfs.c +++ b/drivers/base/power/opp/debugfs.c @@ -41,16 +41,15 @@ static bool opp_debug_create_supplies(struct dev_pm_opp *opp, { struct dentry *d; int i; - char *name; for (i = 0; i < opp_table->regulator_count; i++) { - name = kasprintf(GFP_KERNEL, "supply-%d", i); + char name[15]; + + snprintf(name, sizeof(name), "supply-%d", i); /* Create per-opp directory */ d = debugfs_create_dir(name, pdentry); - kfree(name); - if (!d) return false;