From patchwork Thu Mar 9 16:00:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13167774 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D057C74A5B for ; Thu, 9 Mar 2023 16:03:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231781AbjCIQC5 (ORCPT ); Thu, 9 Mar 2023 11:02:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231224AbjCIQCK (ORCPT ); Thu, 9 Mar 2023 11:02:10 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC633F4B43; Thu, 9 Mar 2023 08:02:09 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BFF1922148; Thu, 9 Mar 2023 16:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678377727; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+o0nKnK7DSPy1Ib3Bv1R1mVbwQPH782fXsSg9TrWayg=; b=ds9BVXOXcsc0L1GpIOU5m5mEsLa2GZFmgjUEVW1kVdMlOc11Zz4N8EAov+7woqI7LF5+3C sq74CAdP0eh2oIhJBY/S+ftDm3zDFektGWxf5t6SBO+dvPbVX0pDSj82wnHpRt0M224YBN kJ9+VNHyI5Ewx5Dbkx2LfsAw983rHjA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678377727; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+o0nKnK7DSPy1Ib3Bv1R1mVbwQPH782fXsSg9TrWayg=; b=cAXmDe1ZXcW9Oq/X5vQNlcBGtv2ULwaGXsQK4pBNgTlpeAJLp/70WKkMESVoPnTLdPQZtx sQ55D/b67gXXUwDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 611E013A73; Thu, 9 Mar 2023 16:02:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UGDFFv8CCmQHbgAAMHmgww (envelope-from ); Thu, 09 Mar 2023 16:02:07 +0000 From: Thomas Zimmermann To: deller@gmx.de, geert+renesas@glider.be, timur@kernel.org, rdunlap@infradead.org, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 008/101] fbdev/arkfb: Duplicate video-mode option string Date: Thu, 9 Mar 2023 17:00:28 +0100 Message-Id: <20230309160201.5163-9-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309160201.5163-1-tzimmermann@suse.de> References: <20230309160201.5163-1-tzimmermann@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. Allocate the copy's memory with kstrdup() and free it in the module's exit function. Done in preparation of switching the driver to struct option_iter and constifying the option string. v2: * replace static memory with kstrdup()/kfree() (Geert) Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/arkfb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c index 60a96fdb5dd8..98c710cadaab 100644 --- a/drivers/video/fbdev/arkfb.c +++ b/drivers/video/fbdev/arkfb.c @@ -97,6 +97,7 @@ static const struct svga_timing_regs ark_timing_regs = { /* Module parameters */ +static char *mode_option_buf; static char *mode_option = "640x480-8@60"; MODULE_AUTHOR("(c) 2007 Ondrej Zajicek "); @@ -1178,6 +1179,7 @@ static void __exit arkfb_cleanup(void) { pr_debug("arkfb: cleaning up\n"); pci_unregister_driver(&arkfb_pci_driver); + kfree(mode_option_buf); } /* Driver Initialisation */ @@ -1196,8 +1198,10 @@ static int __init arkfb_init(void) if (fb_get_options("arkfb", &option)) return -ENODEV; - if (option && *option) - mode_option = option; + if (option && *option) { + mode_option_buf = kstrdup(option, GFP_KERNEL); // ignore errors + mode_option = mode_option_buf; + } #endif pr_debug("arkfb: initializing\n");