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: 159343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp1569973vqb; Sun, 29 Oct 2023 00:53:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4CuxrbCI7rPC3PjDYcCaUQiQtND2Kf7+BIU69agjtP/iyXXAnFT2ZyBQ5cnhLA7IJa9Qo X-Received: by 2002:a05:6870:d8cf:b0:1d6:5b09:1584 with SMTP id of15-20020a056870d8cf00b001d65b091584mr10100654oac.5.1698565992538; Sun, 29 Oct 2023 00:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698565992; cv=none; d=google.com; s=arc-20160816; b=pLIOk4i8tTWqPTb3WuHCQj1PwPZtFUC/vIHjO//yYM6cTn1FYKpoMJuNNRYQQb3Dvw mBmniM6FRLWZPNhRYhavXjKrCWJu9cPJCWVj/HTqlmG97zNxQEn+HjKT8nDzKhHWR/pC vG6CuQqfftcWh+zOLVo0wex2Bd2ZtLx9yOJUGxxXI4h9G6dRXwIncC7W4aaUZ+EkPOdr /iBQ4r2vjfB14wGbPbOLmqO43NLAWrj8ipHqu4SB5zZvtcDwPduJXs0P4vN97m6cYhRl dSZpmCYKHwAMNXwyTtapmDsEch56B8ZUd1plzQMPNMDcz89FCsw0z/m9Uh4aKAq3GTwd tk2w== 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=aXnsQa8QKoNJcBcPyfHeo4PkQFM1z9XmPc+yVIVeH5U=; fh=zs8zTmMIA5MORkARml2ezU7DLRDXZbUnigEVRzMPYuY=; b=G322cEDoUFc2PcuyuK4KvrItzTmXgj4NeFAGybEpzwNhiwQqYVNiE1Fal4SK38nKbH pTwuGcxB2j4A3ILp9YWRWmfPz6JWIpUPz23kaXWKaWLVFBAYJ72d5Io3o4zMP2xNQfnN ls1wo0cXeHXBr1xjJ5dRx0q1uwiChxdqj9B4z7DD69rw61zxeLNYPf4GmZltF+7zgz7Z uMIcZo15rPkWqdVNOvEWB5bKVRx+CjPJYlmg4fVb1XcuPsi9vpk6WGaPMMDBDohsiDQs s5TgciZhBGxIWYNtrLuj+Cx61N2UgOy/Lhj/dAwfxL913p3OPzIWf1syMQlCqdECtfLn QQ6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=pEE4unCD; 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id 125-20020a630183000000b0057cbd803b30si3434412pgb.654.2023.10.29.00.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 00:53:12 -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=pEE4unCD; 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 4AA4D8058B72; Sun, 29 Oct 2023 00:53:10 -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 S229805AbjJ2Hws (ORCPT + 30 others); Sun, 29 Oct 2023 03:52:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbjJ2Hwq (ORCPT ); Sun, 29 Oct 2023 03:52:46 -0400 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BB47D6 for ; Sun, 29 Oct 2023 00:52:44 -0700 (PDT) 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-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]); Sun, 29 Oct 2023 00:53:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781075534600309704 X-GMAIL-MSGID: 1781075534600309704 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);