Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4725001imm; Tue, 9 Oct 2018 04:24:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV61M9pubZvN/FktCX3ftUhVflCtco1yPq9PsOJeST4rg2wkpFAn2lm4RLY1fPxY6d7CcCgHp X-Received: by 2002:a63:bd01:: with SMTP id a1-v6mr8478916pgf.58.1539084289343; Tue, 09 Oct 2018 04:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539084289; cv=none; d=google.com; s=arc-20160816; b=PpRlrpNDjB+kVrzGOE7MLhk8U3gKPMM7jjoxJ2buhp7VqVeEVs4QXj4oHdyEs0XeyT yJ5KWaKHNA9ult+AR/BSveeCCR3X+lNV/lpuLqx1bPsORMzcq+sGHjDWE3K+2YXnSCyE u059O15sM0x/o/c6zBS2noICFyxlN5RqqMKXYvw9/fxjLLv14QoZ/YsVHYlbYWySV8ky t2AJhJ5Tjh8wSfWtPbwpfotXGTpHJ0ZM7YTKN7d/m98MCTgiXFhqWqHGT+/EGCEVEaB4 ojB0LHyeBjICJn6CLQxHq7s968WVGcZsE+W21yzVZvF1JvWA68PqavIIHyvsy0SIQhHZ nlBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jpI9C9cAotX3nj8y5pIFi8JfUs0lkIoRNOT0l40fByE=; b=wjwOhFk8Q6caNgUwKDPydbZcGr8+dl3FH+smnSWu382wdo8CsU8rzT/7YdsR4BzLjT EcuSkjrJa9w5Z62w7LbekaCVFeOeA0Hi6T55SOxVKiLQvBSw5rqHTa5VEsBJRKeUJS6f KpMPy4ZSqBmhgDXW6qcka0bzxrURsK6XtGvdHH6zxo49Fww5OEhphEIXchL45ROQWUUE 8R6fd71a/MAtC2byST1ZHMpxtjTDG9rLBfrwYIH/UvuSGaB0Tv7RK6cq5tgunuHeEHDw pig55DDi6wJi5qc8pTTExlxnC2fVA+RW6K1lufVeFQGGN/JxSf9bwESBDsxa+APSFGf+ tY8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=e34y7uTm; 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 x32-v6si21620380pld.323.2018.10.09.04.24.35; Tue, 09 Oct 2018 04:24:49 -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=e34y7uTm; 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 S1727346AbeJIShA (ORCPT + 99 others); Tue, 9 Oct 2018 14:37:00 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:40857 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726991AbeJISg6 (ORCPT ); Tue, 9 Oct 2018 14:36:58 -0400 Received: by mail-ed1-f68.google.com with SMTP id r1-v6so1319348edd.7 for ; Tue, 09 Oct 2018 04:20:29 -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 :mime-version:content-transfer-encoding; bh=jpI9C9cAotX3nj8y5pIFi8JfUs0lkIoRNOT0l40fByE=; b=e34y7uTm8jShjNOW10FJBZ0xQCDSjslMJQZs0VUme9zLH0AmNBU7Laqwckmgd/6YOg 5H7ZSrRUQpD725uu3gRXAiLCvCXqYJ/gabZxizuNyOZSnG2CHY9c6ZCqvgMclJaR5+LT /r5Y6TGvtZoBlefUQzDBDedUwFMgq1SRj4QTQ= 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:mime-version:content-transfer-encoding; bh=jpI9C9cAotX3nj8y5pIFi8JfUs0lkIoRNOT0l40fByE=; b=UMxe81L/lB4YSIlk2h6u1mVgB+pgiGYpFH1iJCtO/zzF4vd/R7pD2613WZ40XdaDyT /OFxWavFNpU9UUeG4y3nK9+zG0wyuI43m/HSCsWHG1uP4FI80H8n3h3TgIWAue3adjKJ wLnUooPMfpIy0LDpNnsskC3XbMx4onDE331+VTKgTRZJO2BpDPL83K69Kl184M6eaz9V fA2adllgthkHM0aVxp7Evjiz5ocROknppDCa+HiNTYtR/bzIxXCoxTaThtpgIsuAY0Ll oh9TPQat1LZUvYaGjDnsBpY/mUziebD+UR1E0WvFCtdOQ8RSWBkOrPcJNb2U67aIcdNB lf/Q== X-Gm-Message-State: ABuFfoj2+ctVUNmLqtwDnahsyRdpCVNshPv/0AtIB5a9L2My1sz5K0PI yHJlCxFt/iSGAdvkCKMRaE0FWA== X-Received: by 2002:a50:aebb:: with SMTP id e56-v6mr34344583edd.16.1539084028446; Tue, 09 Oct 2018 04:20:28 -0700 (PDT) Received: from prevas-ravi.vestasvisitor.net ([193.47.71.171]) by smtp.gmail.com with ESMTPSA id n23-v6sm3595821eja.41.2018.10.09.04.20.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Oct 2018 04:20:27 -0700 (PDT) From: Rasmus Villemoes To: Jason Baron , Andrew Morton Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes Subject: [PATCH v2 08/23] dynamic_debug: don't duplicate modname in ddebug_add_module Date: Tue, 9 Oct 2018 13:19:58 +0200 Message-Id: <20181009112013.14238-9-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.19.1.4.g721af0fda3 In-Reply-To: <20181009112013.14238-1-linux@rasmusvillemoes.dk> References: <20180919220444.23190-1-linux@rasmusvillemoes.dk> <20181009112013.14238-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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(). Acked-by: Jason Baron 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.19.1.3.g1d92a00e68