From patchwork Sun Oct 29 07:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13439745 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 95051C4332F for ; Sun, 29 Oct 2023 07:53:15 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=A3+AHxsz9/PSPkvVTZtM5yvIr8+iNElDGcl6KV3z/PA=; b=CeOtzEm2dDv0tW OLRMxSG5F52t44+4nbx9/tCdZ7IpPoE3VcBb3lzcrrNeXdhA7QXqdYZuANko8pwECbozzzuu1o4YS lvQTgM+8I8Nu8661yAcP0m4eiS9OY9z1b32zy0uUT+8nCKckV/c6ldNQz9I34llRR5M+uK3e554+K qQH39CIy7LrGScRHUBfo2gwpKGHLfjj8LQ7vPWvm0v0/Skh+B3GezWfox9yrSYIJyIbkhwNosp0Yo d1TGzazf57rFe9SiHfHqEGJZEipt08+DPfNCP8aZuD2m6dxIendrTsPuoIjpEi1bu1mp2fUZRpC4K EuRWib63/5Mg3t7w6x8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qx0bK-001LTO-2m; Sun, 29 Oct 2023 07:52:50 +0000 Received: from smtp-21.smtpout.orange.fr ([80.12.242.21] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qx0bG-001LSn-1T for linux-arm-kernel@lists.infradead.org; Sun, 29 Oct 2023 07:52:47 +0000 Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id x0b8qrtw4dj4Ix0b8qBkib; Sun, 29 Oct 2023 08:52:42 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1698565962; bh=aXnsQa8QKoNJcBcPyfHeo4PkQFM1z9XmPc+yVIVeH5U=; h=From:To:Cc:Subject:Date; b=pEE4unCD2vcRQHf6N/wDjcR80QbYtMJB0BhuTadKRK5e3Nhj+qg8zMuASpCgZffCO VYsJ57zIZHUllW57CbwKPQCaZgp9MdGj1QTNlkEaNiZ4/rzxbzOqd6tslpy4e+4A5u eL9RXrf3wi+j9KRzRGpzjM1VdXDjgulTMuu5lmYWdZWtVNFWFZKjfNNnO3V4b55ekB zMWn0xlyi7ArvB7PHppRk/epfxjzWP0Do2zgCVe43O3JYtFz9MBnO51jWirKi9uKnQ q9FkWGCfqtddSFV384CGKeKjKvmeZ9Ai6ENJzQSZZ3AQg3ptI8tS0pqJHu67U4+gku R6+T3xztTd2gg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 29 Oct 2023 08:52:42 +0100 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Nishanth Menon , Tero Kristo , Santosh Shilimkar Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Tero Kristo , linux-arm-kernel@lists.infradead.org Subject: [PATCH] firmware: ti_sci: Fix an off-by-one in ti_sci_debugfs_create() Date: Sun, 29 Oct 2023 08:52:36 +0100 Message-Id: <880aeea52f3bdde5e3e8843bbedb7fd068a58be2.1698565938.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231029_005246_629342_4929AB9F X-CRM114-Status: GOOD ( 10.88 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The ending NULL is not taken into account by strncat(), so switch to strlcat() to correctly compute the size of the available memory when building 'debug_name'. Because of the difference in the return type between strncat() and strlcat(), some code shuffling is needed. Fixes: aa276781a64a ("firmware: Add basic support for TI System Control Interface (TI-SCI) protocol") Signed-off-by: Christophe JAILLET --- drivers/firmware/ti_sci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 7041befc756a..1036c6b0f3eb 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -181,10 +181,9 @@ static int ti_sci_debugfs_create(struct platform_device *pdev, /* Setup NULL termination */ info->debug_buffer[info->debug_region_size] = 0; - info->d = debugfs_create_file(strncat(debug_name, dev_name(dev), - sizeof(debug_name) - - sizeof("ti_sci_debug@")), - 0444, NULL, info, &ti_sci_debug_fops); + strlcat(debug_name, dev_name(dev), sizeof(debug_name)); + info->d = debugfs_create_file(debug_name, 0444, NULL, info, + &ti_sci_debug_fops); if (IS_ERR(info->d)) return PTR_ERR(info->d);