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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 07B68C636CC for ; Wed, 1 Feb 2023 02:46:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LkoAOcoag7pKY0ROF7suMB9njxr9Zz3TpW+PZbmKMno=; b=UrIGFxODvrY4p0pSeWG9p3I6GB PhmEU2U0RHV+lj/Ar5lrJwecVGo0w3rqwFka5sMxweRiHXJ62LC6jkUzkJwRpwPmhRcQAzHNvkk68 3uU3OIaL+F5e53uMaiIGwc4M/trGav5FE0kCQsfJNPkvHyArCo6lzaDQ3dDmBFyFxSgY9ihbHNpiX NTe4LPSWGw0GkNcaRYg4gxVDtDJO2mjMS75NPjrj8v8zaREqvcLqdrmbrIR8z51pTALgmyVgOMkJx UXWbRc8GX+GT+PoVo/KcjYJQSPq/eMey08PdQj1dBZ2Lrhd26jP+p0LVMXeNzCPEteeja02t5ZuAV bOcvPv7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pN37Q-00A1Mf-Q1; Wed, 01 Feb 2023 02:45:04 +0000 Received: from air.basealt.ru ([194.107.17.39]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pN37M-00A1Lr-Un for linux-arm-kernel@lists.infradead.org; Wed, 01 Feb 2023 02:45:02 +0000 Received: by air.basealt.ru (Postfix, from userid 490) id 61C342F2022B; Wed, 1 Feb 2023 02:44:59 +0000 (UTC) Received: from localhost (broadband-188-32-10-232.ip.moscow.rt.ru [188.32.10.232]) by air.basealt.ru (Postfix) with ESMTPSA id 8C6B22F20227; Wed, 1 Feb 2023 02:44:57 +0000 (UTC) Date: Wed, 1 Feb 2023 05:44:57 +0300 From: "Alexey V. Vissarionov" To: Greg Kroah-Hartman Cc: "Alexey V. Vissarionov" , Krzysztof Kozlowski , Alim Akhtar , Jiri Slaby , Thomas Abraham , Kukjin Kim , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-serial@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH v2] serial: samsung: fix buffer size for clk_name Message-ID: <20230201024457.GD446@altlinux.org> References: <20230116141658.GC8107@altlinux.org> MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230131_184501_376213_1704BA41 X-CRM114-Status: GOOD ( 14.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============5156470644542671788==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============5156470644542671788== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+pHx0qQiF2pBVqBT" Content-Disposition: inline --+pHx0qQiF2pBVqBT Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable serial: samsung: fix buffer size for clk_name Although very unlikely, the 'clk_num' value may be as big as 2**32 - 1 (uint32_max), so the buffer should have enough space for storing "clk_uart_baud4294967295\0". Also, the numbers in clk_name are expected to be unsigned. Found by ALT Linux Team (altlinux.org) and Linux Verification Center (linuxtesting.org) using SVACE. Signed-off-by: Alexey V. Vissarionov Fixes: 5f5a7a5578c5 ("serial: samsung: switch to clkdev based clock lookup") --- On 2023-01-19 15:52:38 +0100, Greg Kroah-Hartman wrote: >> Fixes: 5f5a7a5578c58852 ("serial: samsung: switch to clkdev >> based clock lookup") > Please fix your scripts to use the proper number of SHA1 digits > in a Fixes: line as the documentation asks for. Done. Also added the comment to the source regarding the buffer size. diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_= tty.c index 0fce856434dafd80..2c701dc7c6a37191 100644 --- a/drivers/tty/serial/samsung_tty.c +++ b/drivers/tty/serial/samsung_tty.c @@ -1407,7 +1407,7 @@ static void s3c24xx_serial_pm(struct uart_port *port,= unsigned int level, * */ =20 -#define MAX_CLK_NAME_LENGTH 15 +#define MAX_CLK_NAME_LENGTH 24 /* "clk_uart_baud4294967295\0" */ =20 static inline int s3c24xx_serial_getsource(struct uart_port *port) { @@ -1457,7 +1457,7 @@ static unsigned int s3c24xx_serial_getclk(struct s3c2= 4xx_uart_port *ourport, !(ourport->cfg->clk_sel & (1 << cnt))) continue; =20 - sprintf(clkname, "clk_uart_baud%d", cnt); + sprintf(clkname, "clk_uart_baud%u", cnt); clk =3D clk_get(ourport->port.dev, clkname); if (IS_ERR(clk)) continue; @@ -1957,7 +1957,7 @@ static int s3c24xx_serial_enable_baudclk(struct s3c24= xx_uart_port *ourport) if (!(clk_sel & (1 << clk_num))) continue; =20 - sprintf(clk_name, "clk_uart_baud%d", clk_num); + sprintf(clk_name, "clk_uart_baud%u", clk_num); clk =3D clk_get(dev, clk_name); if (IS_ERR(clk)) continue; @@ -2522,7 +2522,7 @@ s3c24xx_serial_get_options(struct uart_port *port, in= t *baud, /* now calculate the baud rate */ =20 clk_sel =3D s3c24xx_serial_getsource(port); - sprintf(clk_name, "clk_uart_baud%d", clk_sel); + sprintf(clk_name, "clk_uart_baud%u", clk_sel); =20 clk =3D clk_get(port->dev, clk_name); if (!IS_ERR(clk)) --=20 Alexey V. Vissarionov gremlin =F0=F2=E9 altlinux =F4=FE=EB org; +vii-cmiii-ccxxix-lxxix-xlii GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net --+pHx0qQiF2pBVqBT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCgAGBQJj2dIpAAoJEFv2F9znRj5KU4AQAJvU1W+saE+0cNg53LGU0MmJ 7+PqoS3fqV8VPmXLbNIwPijOAz4n0KwJJLmYiefF1irhPQ1V2sZ6+j6GbvPRl4UG 78reDDY1mp3sAMGzFoeoVI3mcPzCiVr4yvs03BSq2Y3dX9HdEZspmO87DpO+L56A s+Rke3F41eh21luK+5H8TvhPnbFKjZhtsb9dTHCV5zyfQg+EGeCW99IjPW8rcyvL 3xN4d2+ZsxKzgWX/cR6cY+XsxrE/lGVvl5z6+qLUfXZnRbXeckTfgQT6F4MGMFxd rGZkJ1vfc/9SCXXd1vVl0HWJDhQ1bLVX6FRuqaSizg6ET+jbbksNXP9yt4+VJXUG HJh0GrbzCKMYYq3r3Crsr1f68NJ0Z8NTKEp9bO2/QHtnOXi9V6Tl08EjtRPrF/v5 I3QY6BIHjeS9QqXcIYwmJFBxLn9vZgnZEBC1kGkOy9OwfniHBt5mEmo5T+p6pcZ9 Wxvq7jAUEfzmuIE2h4CTw7nxP8Zb1GPCQh217j8pWx608QOv4yb3WeqAdhmND/R4 8gT9E4mpKqQ1TdswW6ha1IHCEmjpgzL4PhUoBizNnoXCyZOUC0DKDKrxPCoj2qCt W0ks13V+0j0Xo30CrtJ59CmtbXgBIAAgn63PskyQYgpwmsKmoyAdSmfIq6wZfl6F 8W8j4ddNGWLu2vLk1Sul =31x7 -----END PGP SIGNATURE----- --+pHx0qQiF2pBVqBT-- --===============5156470644542671788== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============5156470644542671788==--