Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1254722imm; Wed, 19 Sep 2018 15:07:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaELJ/0Di6Q8Omt2gH1s6MVLg4kMDDogQVDRL+aI6+E2RZYMFDkV8OGKg5jAzI24v6ljsO4 X-Received: by 2002:a62:880c:: with SMTP id l12-v6mr38662367pfd.204.1537394846896; Wed, 19 Sep 2018 15:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537394846; cv=none; d=google.com; s=arc-20160816; b=frwjOrQmq5NBGW0rjNdv6TiziYPc+o6Uu5mh6C/Y5HqWrlCzXyX/5/LfIcQMG4MDrn ofsqe4VsON3K1rmM9Q1Wc+TSLv9M5xO8pJBc9I+xu0Ik1ilMWFH0eSogeOAF+lIDK2D3 0wWurCvgkcl+OxF4XSNVvIpgApfbaW771qXv8l5/dCGcTFp8cV9gUyVkNd3wOSsSQi3X bLT7f55pPC0yIeIVy7yCFsSsIs239jVaR9krE9MU1yfSBJmBXThw7hUsYPL7nSa5sI0n v/P78/w0yRBiI1FZsvmuteZ64aqdYTJTlXcv+H7t9JagCLJPb3CRofAOO4DDzwQZC61F rYVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=UoBATMlLiphiO4fBYy7pZc/Q/hO4r+d5OoEnXv60dX0=; b=wt06a7OpG12/ZAb2CUkeHBYWAwcsXboBW/u/Vu0V2gEDg7cXye1k08YLFqQ+XHAF9G UKHUkPZFPgdKvwXwXGgPlnkI8/Vf8//G9jMvf+gRgxFNyief8dVmi2acI1eXGGIcetyW VlDTfWt8aBqExwYpavJm9jsdnUF4p5qb9onJb7Ks5cYy9eJcSlr0Trc8OFkT7dHMEj23 HxyGrXqeFRWP1fN49nphExmrEi45Hh7xezCcB+DrI+NzKgieIkeJneV/gT/R329Q7KUw oxIgpSbACuaH3/QVEdEXTNPxUQ0QL6UYv+7o1XkO8L0SFepb5y/udGwRGRq2sUJ9lPNp n65Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=MOdHFXiV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y127-v6si22114730pgy.278.2018.09.19.15.07.11; Wed, 19 Sep 2018 15:07:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=MOdHFXiV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387400AbeITDo6 (ORCPT + 99 others); Wed, 19 Sep 2018 23:44:58 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:43197 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730876AbeITDo5 (ORCPT ); Wed, 19 Sep 2018 23:44:57 -0400 Received: by mail-ed1-f65.google.com with SMTP id z27-v6so6147383edb.10 for ; Wed, 19 Sep 2018 15:05:00 -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=UoBATMlLiphiO4fBYy7pZc/Q/hO4r+d5OoEnXv60dX0=; b=MOdHFXiVNFphi0EmPYkUv58hle7enqd+AdXbhbu4inZgX6QstmZg3HtY0V9xxJUV5O HxsJhbmgBeWofxhh9/A1pz8dVG5VVXn8xDbEg5N+MdnsNGWcQmvVs6ChvZ0FOurt93Xt mYTgYdvQGocKhMuDzeXpe7sxXP07sEwg1uWZE= 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:in-reply-to :references; bh=UoBATMlLiphiO4fBYy7pZc/Q/hO4r+d5OoEnXv60dX0=; b=H1PdxaDkSYPpwZqyn314YJCXb4BvrTMJHIkO0NTdBCtqUntIH9sZC/6wlcWwyn1Nip HRZctb8nP+LFL0jT0YJHdJQ91d1Y3vy2VjAeQ9f/n9xbKrzjY0/SDTUqP0QKIk1qDKfb vL0Y08Q+Jm4Tgcn88R5aqgdIhlZGvc7bIZE9wlJ6WezLi9W+UshiZlbB6acq7I1ee41d S368EG5yYXJtPaktjUadC9mC0VfW8scIEcIlwrjiBTAngTV4ZKfE+5rFaUw8Fq0HINs2 OQ6rGbpsSmJEmlwNBaUjnmgEAiCF18c2mx046MuJFvR9RuQQedFEjYFEiPjDqOfo29OW xqyg== X-Gm-Message-State: APzg51BAcTIJuZ/C6n560i1LRk+AazGpIXfFziD3VUE8ovqA/EFF/WN0 ehVEGOI0iFbJKXa4xw8PBEmuoFa24LVjEpMn X-Received: by 2002:a50:9297:: with SMTP id k23-v6mr63646772eda.180.1537394699918; Wed, 19 Sep 2018 15:04:59 -0700 (PDT) Received: from prevas-ravi.waoo.dk (dhcp-5-186-115-161.cgn.ip.fibianet.dk. [5.186.115.161]) by smtp.gmail.com with ESMTPSA id a9-v6sm2798edi.26.2018.09.19.15.04.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Sep 2018 15:04:59 -0700 (PDT) From: Rasmus Villemoes To: Jason Baron , Andrew Morton Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes Subject: [PATCH 08/22] dynamic_debug: don't duplicate modname in ddebug_add_module Date: Thu, 20 Sep 2018 00:04:30 +0200 Message-Id: <20180919220444.23190-9-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180919220444.23190-1-linux@rasmusvillemoes.dk> References: <20180919220444.23190-1-linux@rasmusvillemoes.dk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For built-in modules, we're already reusing the passed-in string via kstrdup_const(). But for actual modules (i.e. when we're called from dynamic_debug_setup in module.c), the passed-in string (which points at the name[] array inside struct module) is also guaranteed to live at least as long as the struct ddebug_table, since free_module() calls ddebug_remove_module(). Signed-off-by: Rasmus Villemoes --- lib/dynamic_debug.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c7c96bc7654a..2155e0e23530 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -847,17 +847,17 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, const char *name) { struct ddebug_table *dt; - const char *new_name; dt = kzalloc(sizeof(*dt), GFP_KERNEL); if (dt == NULL) return -ENOMEM; - new_name = kstrdup_const(name, GFP_KERNEL); - if (new_name == NULL) { - kfree(dt); - return -ENOMEM; - } - dt->mod_name = new_name; + /* + * For built-in modules, name lives in .rodata and is + * immortal. For loaded modules, name points at the name[] + * member of struct module, which lives at least as long as + * this struct ddebug_table. + */ + dt->mod_name = name; dt->num_ddebugs = n; dt->ddebugs = tab; @@ -913,7 +913,6 @@ int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *module) static void ddebug_table_free(struct ddebug_table *dt) { list_del_init(&dt->link); - kfree_const(dt->mod_name); kfree(dt); } -- 2.16.4