From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 133AAC54E49 for ; Sat, 9 May 2020 23:42:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E422F217BA for ; Sat, 9 May 2020 23:42:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PA3J3jqx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728943AbgEIXmQ (ORCPT ); Sat, 9 May 2020 19:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728279AbgEIXlL (ORCPT ); Sat, 9 May 2020 19:41:11 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E2C5C05BD09 for ; Sat, 9 May 2020 16:41:10 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id a7so5932953pju.2 for ; Sat, 09 May 2020 16:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a6bXV7bt3FJwO+6h7hS9wdbWbj+cKT2R8klgQdvy5V4=; b=PA3J3jqxZhR7QLeqwjId3MPNynQJYjylfFHuFHDO93eKIYh0iQYwhqZLfhDgt0tNPx NxHMmZui4QlIyuKxLjsRMXG4PNIvSBqEGu3OoFLfiibivil4eA41JBZI/UtGxAjYryLj xFanC6zXk4byjitJUGh5BrMI4F3rjAjk6STjc= 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=a6bXV7bt3FJwO+6h7hS9wdbWbj+cKT2R8klgQdvy5V4=; b=FnYQtL8Q7sFFyXYp/tQYINLyBQztA7PJr6JRj6QnZiNgm5KXmg0mnVlKQ7q5bBQ4B0 nS4m+4OiRerQ1MVb9dQ33xgUP/diw7PQgYhi6yoSYTnsWzYllbE4h7AS40ZaiNtC9AT+ /EAS7nnBvMXeYQyuJw++cz1PU1jlIxdUmnh69GXknBsdeBVozJyJJJkCgvcbw6i6y5am UTSht/KnBnd0st7YzCym5i1y2bKgU+QV7Yn0CVJNlxGCk+ODrMI0LxBLm28k0Ai9GqlR 3TV7KwYZs8TUUttm84eQh7oF0vihoISoW5+SG71nUwB11arsiXbdUBthLJV4VYVmhZIa c3SQ== X-Gm-Message-State: AGi0PuZ/jfgTK6CWGbePUk0WtXCRILGntJf6D8smMzE/VkAHNIZFD14Z nt+cQO8g7gZyAl52Y7mWH7GRZw== X-Google-Smtp-Source: APiQypIYGFFNE4CP/IEMoDRh7mGwo0o4z+2NMypaNjHCF3aRnPBRNu9ocJUCntHiguWss1r6vpDHyg== X-Received: by 2002:a17:90a:8b82:: with SMTP id z2mr14034741pjn.124.1589067669999; Sat, 09 May 2020 16:41:09 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id n23sm5722167pjq.18.2020.05.09.16.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 May 2020 16:41:06 -0700 (PDT) From: Kees Cook To: WeiXiong Liao Cc: Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck , Jonathan Corbet , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Rob Herring , Pavel Tatashin , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH v6 02/18] pstore/platform: Switch pstore_info::name to const Date: Sat, 9 May 2020 16:40:47 -0700 Message-Id: <20200509234103.46544-3-keescook@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200509234103.46544-1-keescook@chromium.org> References: <20200509234103.46544-1-keescook@chromium.org> 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 In order to more cleanly pass around backend names, make the "name" member const. This means the module param needs to be dynamic (technically, it was before, so this actually cleans up a minor memory leak if a backend was specified and then gets unloaded.) Signed-off-by: Kees Cook --- fs/pstore/platform.c | 3 ++- include/linux/pstore.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index b882919b8784..e7bf22f01928 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -626,7 +626,7 @@ int pstore_register(struct pstore_info *psi) * Update the module parameter backend, so it is visible * through /sys/module/pstore/parameters/backend */ - backend = psi->name; + backend = kstrdup(psi->name, GFP_KERNEL); pr_info("Registered %s as persistent store backend\n", psi->name); @@ -669,6 +669,7 @@ void pstore_unregister(struct pstore_info *psi) free_buf_for_compression(); psinfo = NULL; + kfree(backend); backend = NULL; mutex_unlock(&psinfo_lock); } diff --git a/include/linux/pstore.h b/include/linux/pstore.h index 16a1fdafc167..eb93a54cff31 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h @@ -176,7 +176,7 @@ struct pstore_record { */ struct pstore_info { struct module *owner; - char *name; + const char *name; struct semaphore buf_lock; char *buf; -- 2.20.1