From patchwork Mon Mar 6 15:59:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 64854 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1923856wrd; Mon, 6 Mar 2023 08:04:57 -0800 (PST) X-Google-Smtp-Source: AK7set90LaHGR1ECGEowRvgQOD29WLVTnE8dMihxvzCwI+mooTOUmhd7q8C0gVA3K8RdRqodunQ5 X-Received: by 2002:a05:6a20:d021:b0:cb:df6c:acfd with SMTP id hu33-20020a056a20d02100b000cbdf6cacfdmr8642537pzb.52.1678118696755; Mon, 06 Mar 2023 08:04:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678118696; cv=none; d=google.com; s=arc-20160816; b=k+m9Y4XdA0GTuJvLtc1Pl3w5lCKr7TGH3vqpR7PW2Ove7oyHpG+J9dtj8e1R51MbIK KgWVbRFrOfRrsHvQfR9s7k1oKrTjrpj6X7JTs4pQaxNIi4CpJdrUE2mwJUGApvXrdXYW 38y0orjVkxjlghyWhQj+Q4yW0EMhwTsm/mI2LAQtn4zoAWlRDcGo4RCCx/s0qpoumeXG wxjn0JgVjxmoGxFhhjadPvJRUjvSiYwlKeZqK7N036t93o+pA+z3K5XdSm6I9f9TG6WO RQj/+1U1cfrnJKKQcg4j5PCInIJg+RYRo5c728ZMCcVy6F2cH5s6s5gU71YJB6fwR2gH 2uqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=RY3kXDB5O3B2dKeL06A7y/2N+B8soo0q40s9lvLV3c0=; b=TECgebVCV2Nq5qbHJ2dj+zgU6gBVMzYj2uFmnsMAF5yLj70NdKfVGbB0wMyP5afQ+z D6e2ONunQ5uFkI5WI7sYvTpRbXjpc+5wBUhfM+2Ij277QV51gXK2iUuRfgqoRc7ymwsz ILwzXnGxOS2dWgxRJsrn8sTq5vfI4JnEaOFtqf9e7Qzp7yTJxsj87jAZGBOmoCNc0dJA lH5Ni+wivM65DsMKPg+t9QPZzFwArNMjooBpw6hGIkL7Xj9LnnS/moETSDLE4BzPA2qb ddR6qZXmrQu2R19mI7/OHeoXMCKmwPBufzZ1TX5NeG6YfKPGX/2QNklIAocUIJEqcPwW CbUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=dFdmq7Ma; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g142-20020a625294000000b005a9c2c4657fsi8658969pfb.191.2023.03.06.08.04.43; Mon, 06 Mar 2023 08:04:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=dFdmq7Ma; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231410AbjCFQDv (ORCPT + 99 others); Mon, 6 Mar 2023 11:03:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230508AbjCFQAq (ORCPT ); Mon, 6 Mar 2023 11:00:46 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E1F530B34; Mon, 6 Mar 2023 08:00:44 -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-out2.suse.de (Postfix) with ESMTPS id C37991FE8E; Mon, 6 Mar 2023 16:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678118442; 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=RY3kXDB5O3B2dKeL06A7y/2N+B8soo0q40s9lvLV3c0=; b=dFdmq7Maqv9IBxfXjOtZJbinxuRrLnLdsPdKXYEl1qQi/wrhQxu8yr+8McekkWAH/2SmlB 7zKf6taB7830jBxci9VS5tTnFIAKMID+oBDHDZjBQENwb5N42q/gyz69EriiuWzzmYdH8S 7Ry3BWyWak5Iq5j43eCCPntiOLDl5qY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678118442; 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=RY3kXDB5O3B2dKeL06A7y/2N+B8soo0q40s9lvLV3c0=; b=GbyCBA84a/aaAPVwSDmwul2Q+inOSugQYvcb0HUNAJvn/QXdaVWrRao+yY5sfTedrTiO1F EYEYAT8cItDj8+Aw== 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 6679113513; Mon, 6 Mar 2023 16:00:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ENcjGCoOBmQ/PwAAMHmgww (envelope-from ); Mon, 06 Mar 2023 16:00:42 +0000 From: Thomas Zimmermann To: deller@gmx.de, paulus@samba.org, benh@kernel.crashing.org, linux@armlinux.org.uk, pjones@redhat.com, timur@kernel.org, adaplas@gmail.com, s.hauer@pengutronix.de, shawnguo@kernel.org, mbroemme@libmpq.org, thomas@winischhofer.net, James.Bottomley@HansenPartnership.com, spock@gentoo.org, sudipm.mukherjee@gmail.com, teddy.wang@siliconmotion.com, geert+renesas@glider.be, corbet@lwn.net Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Thomas Zimmermann Subject: [PATCH 48/99] fbdev/neofb: Duplicate video-mode option string Date: Mon, 6 Mar 2023 16:59:25 +0100 Message-Id: <20230306160016.4459-49-tzimmermann@suse.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230306160016.4459-1-tzimmermann@suse.de> References: <20230306160016.4459-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759634990447312165?= X-GMAIL-MSGID: =?utf-8?q?1759634990447312165?= Assume that the driver does not own the option string or its substrings and hence duplicate the option string for the video mode. The driver only parses the option string once as part of module initialization, so use a static buffer to store the duplicated mode option. Linux automatically frees the memory upon releasing the module. Done in preparation of switching the driver to struct option_iter and constifying the option string. Signed-off-by: Thomas Zimmermann --- drivers/video/fbdev/neofb.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index 39d8cdef5c97..958111f7d63c 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -2198,8 +2198,17 @@ static int __init neofb_setup(char *options) nopciburst = 1; else if (!strncmp(this_opt, "libretto", 8)) libretto = 1; - else - mode_option = this_opt; + else { + static char mode_option_buf[256]; + int ret; + + ret = snprintf(mode_option_buf, sizeof(mode_option_buf), "%s", this_opt); + if (WARN(ret < 0, "neofb: ignoring invalid option, ret=%d\n", ret)) + continue; + if (WARN(ret >= sizeof(mode_option_buf), "neofb: option too long\n")) + continue; + mode_option = mode_option_buf; + } } return 0; }