Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1331108ybk; Sun, 10 May 2020 13:30:43 -0700 (PDT) X-Google-Smtp-Source: APiQypLt7o1QouD2K/fXA4Sb6eA6Axgpu91U4m/P+dkZah4dF6D6dILHoZmSpTF93wte+WEB27vQ X-Received: by 2002:a17:906:7f0d:: with SMTP id d13mr10956454ejr.312.1589142643295; Sun, 10 May 2020 13:30:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589142643; cv=none; d=google.com; s=arc-20160816; b=Hta6xUsbxyNZNpplYxPQzlNkOEphQtM9JHdGg0xVU2q1QPFybTgPa9Huai9KeHgTDS edY8bbD9E+x3e2eH+NuMI7zujm5u6bgxZKqAPhE2KsPKhPgg3N7yYzbExuRNXrzxM53o UStC+SyPX0HMI7upqGJaZmgpOQgEDiuZ0jgfwz/jNTsQ3CSAaGoKCNzcgh36pcF0MQKW YctBx0u/UciuPZPCaDdnBN1Kn7H7wRh2+7mWKHlkMqdbhl1KYEFD8v1HRbro0ZMW6Z7n uGqDO7h+qeFIxj2nbWD+kpJNe9T/UERGoCkEdNkaxiXcVYu5Nqc7VVPoHhcH9RV/d2kx iVyw== 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=a6bXV7bt3FJwO+6h7hS9wdbWbj+cKT2R8klgQdvy5V4=; b=ZLJofrI+ElGwXx8z2ewcvEfqNmfJw8YbvKw3WFCewC0C4vUVJ5X3AhcpfFPq6jobLx Bi6yfJmVHoUJOIKXiYZvQv6JatHHJHL0gZuK0DNsBTy7B1mu2vpzV4WGQNlBDcHUrezY qH1f6LkAHliT9lkTKsG4iZ3BEyGXtQ9nFQ+2rtlcbFyYDXqRH/EgpNUoFrGIzfEIMvCh UdOdLIrSqI4Ygc+BIVgJWLZVAmR5llNyzI7y8ZxvUDcLEFJJp60j4at2ke3+YOOD9FIC Rzz9QUfJHtR/KQclCX6j5hJGs5S/xKtMq5WLHvq/526DJnN0fNCh4zobgKhkeJc7PXYy Gg0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Vu8u0y3g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo7si4743529edb.80.2020.05.10.13.30.20; Sun, 10 May 2020 13:30:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Vu8u0y3g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729351AbgEJUYo (ORCPT + 99 others); Sun, 10 May 2020 16:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729227AbgEJUYn (ORCPT ); Sun, 10 May 2020 16:24:43 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9C20C05BD09 for ; Sun, 10 May 2020 13:24:43 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a5so6763068pjh.2 for ; Sun, 10 May 2020 13:24:43 -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=Vu8u0y3g/EsMOqGf92rFyvezCvoeKBq6M4OIMjHDXZQuVY5ATlo2kh28eB6tVdSW2u HeG9wciptveXO5MHRNtJSHj4Ogkp9s7OktTbZhn/Vvp42lUU1KrIa9rIQ0bGpNOCOKeO EC9TBt8Z9Lh9M/kLz05YI4DHvIcGjrjtQpGgY= 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=rbvQ4eLLiMkD81JjW1viU32/EGpbyFpsn2fQdTCWEgsesrUuT13Fr2VEXhHQgybZpW QJIsAANHjF3smLGvWh7KMe6vbpDkIkFnidk9QHwlk3RrvoeWRMX5sib9SYsK45ds2lbh vgW3jFOE/hMg9vnxeccUktJCqQgitVUtfFCzJXxugJFB05VAxXq+wFVt61nlliyTRylh 13wFVK8wIlcXsMYk27ZsRjlcwZoyrQXYDl+oyni4xezSPonP216ZZDefah1gbBwn3pza gJItbrkLkeTjJ/hHbSWr0R+XclbrpZRT952kxWcr8IsWELjlYt9AopiaePlJ8Cg2IAyz GAsA== X-Gm-Message-State: AGi0PuYw12CbfpBkf8VFDNlUJMnFyYGf+wdS+pLO+8moQVQc0VoS2lkJ PJuK8J4oT/T3Gt/zCADoGWR8xQ== X-Received: by 2002:a17:90b:374e:: with SMTP id ne14mr17664828pjb.145.1589142283365; Sun, 10 May 2020 13:24:43 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y6sm7866882pjw.15.2020.05.10.13.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2020 13:24:41 -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 v7 02/18] pstore/platform: Switch pstore_info::name to const Date: Sun, 10 May 2020 13:24:20 -0700 Message-Id: <20200510202436.63222-3-keescook@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200510202436.63222-1-keescook@chromium.org> References: <20200510202436.63222-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