Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2632671rdh; Mon, 30 Oct 2023 03:13:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHghrwFl9sJYs8+WaEpvXSnnhYp4nLRPaq3/BM6zeh1mSJ/W42d4XlnDMpGIexfDd4O53QB X-Received: by 2002:a05:6300:808a:b0:16b:b0ea:b0a1 with SMTP id ap10-20020a056300808a00b0016bb0eab0a1mr6929596pzc.34.1698660785316; Mon, 30 Oct 2023 03:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698660785; cv=none; d=google.com; s=arc-20160816; b=wNw2b9767CYm/JpiNg/6SsdZ/v2++VGbCBbUZGxGmA5SBwZQ7C/ogihxakeJzueQ8g VCncKOe8zP5vUpMwGeOTKZR/Jwr7gN766M+wEkSEKf/vva5ipI5D9RgMY5MtTFgqc8Wq SY2+F9cWGOiDEFOvZYLlDlrDGGaPuY0FlGUfRn28A1P6T6cd+sDL2PXbhxRDLH2l4oSs fx7MhmFy7+zh3RGiCr0ZqdIcFjvODm4M+cq4JBlWEmqCNsiZsct1HC8ShdnO+FbH0u+s SYbePjjlrgjp+8I2CEZbmR0TcqPyrtff1lhboTo3wDzJoa2ft/7gT95dbm7IXobLzEEq 26Zw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=UlJi3Q2/4KzrolD0gZ6MzxC5lWsP/eLAiQtg1TLakIM=; fh=zs8zTmMIA5MORkARml2ezU7DLRDXZbUnigEVRzMPYuY=; b=gwep3tcGU46x3bI1dNWuJWHVD5GRTvychqgxITa4SNDJWY9w+YlACkR/sROcoqebBb gRX7bPPRAJHER2Zjig8n41t66hgHjPBqqMVPN8aEgy+ZrBFY0jNIL7VDqPq7QfRi/4Bv 5kTAKjYwzPL0Rv/fOtGX8UsekicGGtexCVmbDDWAMhQbyKR2SMXph8Vezz3zsXs6vTMU 8ZaYzjqhIwGNggNKVjGGHdu8civug5Cq6Z9YCf8aUhnm9XeQszU7NYEmF9ZsSZvJuChS u01pqAR04ZqdWHIo31z90X4ds3jbKYRR+CvApXAfpgJ6szl7psFGjAEdH3Qe1FuzlFZD Rp1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=VdKt3ZPQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id k15-20020a63f00f000000b0057942bfab4dsi4785243pgh.395.2023.10.30.03.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 03:13:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=VdKt3ZPQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A6FB880ADEE3; Mon, 30 Oct 2023 03:13:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232515AbjJ3KMk (ORCPT + 99 others); Mon, 30 Oct 2023 06:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbjJ3KMj (ORCPT ); Mon, 30 Oct 2023 06:12:39 -0400 Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76FD78A66 for ; Mon, 30 Oct 2023 03:12:36 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id xPG3qqyAE4QsMxPG3qncw9; Mon, 30 Oct 2023 11:12:34 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1698660754; bh=UlJi3Q2/4KzrolD0gZ6MzxC5lWsP/eLAiQtg1TLakIM=; h=From:To:Cc:Subject:Date; b=VdKt3ZPQ1msygyxneY6z561IdGpQL3CanQWxiVuLcgvAXqqX7L+HgUv4v3nXyd47H bUJrFPoICjbtY336Qp6+Q/Wq1Xds9VRAguAGS9Ozf7BDFO951zA9TZFyI9q5tR6du/ HtIf6tW3upFeDjQb70hvaaEWgi56YBGd1J6S9oDYUstT6KtSVM1BMMpta2awG2dZQH ckan5wUNSIKdJX+2PBRYriv1DR4zv7gXrkYfmCYirOGyBupsWyEr9VI+zxptSySldk FDIqpGsL4eHKch/IJNLcwvfWIVZnDWqkUnAB6KM5Nk42+3sQ5VAmMy/0zVlT6oLP1H 3s4F5bO+iCZ7Q== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 30 Oct 2023 11:12:34 +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 v2] firmware: ti_sci: Fix an off-by-one in ti_sci_debugfs_create() Date: Mon, 30 Oct 2023 11:12:26 +0100 Message-Id: <7158db0a4d7b19855ddd542ec61b666973aad8dc.1698660720.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 30 Oct 2023 03:13:02 -0700 (PDT) The ending NULL is not taken into account by strncat(), so switch to snprintf() to correctly build 'debug_name'. Using snprintf() also makes the code more readable. Fixes: aa276781a64a ("firmware: Add basic support for TI System Control Interface (TI-SCI) protocol") Signed-off-by: Christophe JAILLET --- v2: - use snprintf() to simplify code [Dan Carpenter] v1: https://lore.kernel.org/all/880aeea52f3bdde5e3e8843bbedb7fd068a58be2.1698565938.git.christophe.jaillet@wanadoo.fr/ --- drivers/firmware/ti_sci.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 7041befc756a..8b9a2556de16 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -164,7 +164,7 @@ static int ti_sci_debugfs_create(struct platform_device *pdev, { struct device *dev = &pdev->dev; struct resource *res; - char debug_name[50] = "ti_sci_debug@"; + char debug_name[50]; /* Debug region is optional */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, @@ -181,10 +181,10 @@ 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); + snprintf(debug_name, sizeof(debug_name), "ti_sci_debug@%s", + dev_name(dev)); + info->d = debugfs_create_file(debug_name, 0444, NULL, info, + &ti_sci_debug_fops); if (IS_ERR(info->d)) return PTR_ERR(info->d); -- 2.34.1