From patchwork Wed Sep 9 21:59:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 7149441 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 337A0BEEC1 for ; Wed, 9 Sep 2015 22:01:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B97D720684 for ; Wed, 9 Sep 2015 22:01:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D35ED20519 for ; Wed, 9 Sep 2015 22:01:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753019AbbIIWBF (ORCPT ); Wed, 9 Sep 2015 18:01:05 -0400 Received: from mail-la0-f50.google.com ([209.85.215.50]:35537 "EHLO mail-la0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753140AbbIIV76 (ORCPT ); Wed, 9 Sep 2015 17:59:58 -0400 Received: by lagj9 with SMTP id j9so16309278lag.2 for ; Wed, 09 Sep 2015 14:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JiZKs24+TcEqiNfO+WD01gN09aKiFslpjKny0bv2b80=; b=EFyLm4ZCr8k9aL0TgsOThxVdchRTGr66aPwPtNxLHKYGwfBUNeoXcbViXhbjS/gkGB Imi3Gghnbr0OArFvumdkWrSE1zkZobypVGmXJmlbPmP1uWDLVaj2vK1nz6OSpcO3OST2 kI+bjZR17iX/fpGpOfnPdVtb6SylSLurMDmxk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JiZKs24+TcEqiNfO+WD01gN09aKiFslpjKny0bv2b80=; b=Klvh0LjaTNYFCNP+Z3H5ltmQWnAnch16JPq5YCNeKj0pd50313nG7etLVFnYH0ft8G wXHlXt95ENjQCN8PxlqoQSL7DoAHY0jnIwXOhqi2+JzrogJlk8tZZjMaf2zqXWHegts+ kZN/kTGyLlvbrtDi6wc71Yk/iNEC62DYZqlM5bmToUmAq0/LC88KA516tKPjvEopFnU8 NRa9viw3uIXyZQ/MhDrCOtOgK/Wy2JUKwHmuCz3+i1CANTy+2dRkQG/S080Nd9cyImRz AGSY8dMQIBlaZg3tghwoJQNcdkaLTzTXTosWI8ynej7Qr8kXGstuk1rbkm+gzsjugVJs 1r4g== X-Gm-Message-State: ALoCoQmXeT38Q6rKUpNdE0js7FDPVERqn2tsFhXHPcYfVYo4+DUaro7VLoRBUyR0OsUhcAo2kMoL X-Received: by 10.152.37.9 with SMTP id u9mr17656007laj.75.1441835996776; Wed, 09 Sep 2015 14:59:56 -0700 (PDT) Received: from spencer.imf.au.dk ([130.225.20.51]) by smtp.gmail.com with ESMTPSA id f10sm2123029lae.23.2015.09.09.14.59.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 14:59:56 -0700 (PDT) From: Rasmus Villemoes To: "Rafael J. Wysocki" , Len Brown Cc: Rasmus Villemoes , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] ACPI / scan: use kstrdup_const in acpi_add_id() Date: Wed, 9 Sep 2015 23:59:43 +0200 Message-Id: <1441835983-15197-3-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1441835983-15197-1-git-send-email-linux@rasmusvillemoes.dk> References: <1441835983-15197-1-git-send-email-linux@rasmusvillemoes.dk> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Empirically, acpi_add_id is mostly called with string literals, so using kstrdup_const for initializing struct acpi_hardware_id::id saves a little run-time memory and a string copy. Signed-off-by: Rasmus Villemoes --- drivers/acpi/scan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index a3eaf2080707..afaac47eefb4 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1184,7 +1184,7 @@ static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id) if (!id) return; - id->id = kstrdup(dev_id, GFP_KERNEL); + id->id = kstrdup_const(dev_id, GFP_KERNEL); if (!id->id) { kfree(id); return; @@ -1322,7 +1322,7 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp) struct acpi_hardware_id *id, *tmp; list_for_each_entry_safe(id, tmp, &pnp->ids, list) { - kfree(id->id); + kfree_const(id->id); kfree(id); } kfree(pnp->unique_id);