Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1201022rdb; Sat, 7 Oct 2023 17:53:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqnPB8SdAaerSweJitinB7cMtLQisk6CI/4V37LnaXaKOPW5sdAVdztnIGHodqfMFIh1Qi X-Received: by 2002:a81:b402:0:b0:59b:eab8:7ac6 with SMTP id h2-20020a81b402000000b0059beab87ac6mr11237368ywi.42.1696726417323; Sat, 07 Oct 2023 17:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696726417; cv=none; d=google.com; s=arc-20160816; b=N8AnMC0GHL0uzfnHPuJ6LpCXf36IyzP0WOgwrZLexwhiDWCTGZHBnDTfIcQCPj7Msn Ihrtuodtb9/6kXGs5OT8FwdgcJCi6uC02KrZMZXZ72YVR/GMB7T2mm/Y1radqlAOUr9P 24knqV/e+3jnDFwCFzSvyt4BJzYvRGmvxi5C+C0jiyBxpKD67NA1HW6lRp3RHhpzFtlc 3ptPEUZlIe42bLFQEAL9Rx4ZuFzS7rXG4WIVs0vyWins/2/BzgOgRgb2LhYyPIdU5VTE RUwuomkpFScgTe1MplEd6tjmnnurTPYvF25bGGI2+9HTmwzHGiSoCawTQ49Sy2paOAgT KlSg== 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; bh=KL1uV++wOilSOUp/dCUAC4lowOduDRpGsfJWMjI3epk=; fh=hd0KlfFhxrndTITKbVB8OF8mTl4lSuBkKUgWf1nD+1U=; b=no0W4yAvt43DPYp5JU1rNCWCPQDKVEZnkbPe9oMM6b/NH1RX2Kew0FUPQuXPPgM2vK XLoOA1DSRhhDGNrEJWO0uIvrFDXOgg9tOJ0taf75G01SZiraUN+Easg2gVnTpKXBXEwE kRv6xiE/1d1oAIcCPQfYBUfEC3mNf0+wggzcPWTfZVtJdSyEVS+usfukUsw4Jps2sG0Y fbrouwDX6piYGcwBeW9wWfEFzHECa1F9KmYGtlPIU+VhfoV/13fPdCNylydS7QiB8Yhq JYw/HnYGeZSOfpfKaYSERRkyW80CmAhtvtTs0KinTbf+5zyV8zgmrRDlOfh55mq8Ly5d zrUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JZbBvT9F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id m17-20020a170902c45100b001c3f6dbe2bdsi3132857plm.105.2023.10.07.17.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 17:53:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JZbBvT9F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 09336805360A; Sat, 7 Oct 2023 17:53:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234132AbjJHAxO (ORCPT + 99 others); Sat, 7 Oct 2023 20:53:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234255AbjJHAxG (ORCPT ); Sat, 7 Oct 2023 20:53:06 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4F83126; Sat, 7 Oct 2023 17:49:45 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACFDDC43395; Sun, 8 Oct 2023 00:49:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696726185; bh=Nmhz/9BvVrLw0Vg0dq1swMvN31n7A8Cq6GXhQ6SaPJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JZbBvT9FwDXg4pY8M6FBd0wp8D6c0capMS2dTKGUN7l7YEkTd7dkIHr+1l0/eJGRT 1BiASwpQ/lmG7IeqqUo/79DZbi3u5D5HfuZMQnVnz4E+aK1ZvqhA9AODHO0bX6qafe BStGshtyh0T3yMRKGDHAoSB8n5Df0FYxs5jICjH0xGrSvucXnlolKiDBGNJLq+bNtK MDanA7anGLkN3Yi4bZlFXp/PNrUQEj5uzC85KxWWTdhQ0nX6V1hGJYcNIsUCinUlOr ZScK1BbQG47TwDvJ/LHa9/ZjE4w7UIbOB3H/AziDsyRh73yOwDYKcL59RZck+UpKu5 UUgE+SFAg3EQA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Damien Le Moal , Hannes Reinecke , Geert Uytterhoeven , "Martin K . Petersen" , Sasha Levin , linux-ide@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 10/12] ata: libata-core: Fix compilation warning in ata_dev_config_ncq() Date: Sat, 7 Oct 2023 20:49:27 -0400 Message-Id: <20231008004929.3767992-10-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231008004929.3767992-1-sashal@kernel.org> References: <20231008004929.3767992-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.56 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Sat, 07 Oct 2023 17:53:35 -0700 (PDT) X-Spam-Level: ** From: Damien Le Moal [ Upstream commit ed518d9ba980dc0d27c7d1dea1e627ba001d1977 ] The 24 bytes length allocated to the ncq_desc string in ata_dev_config_lba() for ata_dev_config_ncq() to use is too short, causing the following gcc compilation warnings when compiling with W=1: drivers/ata/libata-core.c: In function ‘ata_dev_configure’: drivers/ata/libata-core.c:2378:56: warning: ‘%d’ directive output may be truncated writing between 1 and 2 bytes into a region of size between 1 and 11 [-Wformat-truncation=] 2378 | snprintf(desc, desc_sz, "NCQ (depth %d/%d)%s", hdepth, | ^~ In function ‘ata_dev_config_ncq’, inlined from ‘ata_dev_config_lba’ at drivers/ata/libata-core.c:2649:8, inlined from ‘ata_dev_configure’ at drivers/ata/libata-core.c:2952:9: drivers/ata/libata-core.c:2378:41: note: directive argument in the range [1, 32] 2378 | snprintf(desc, desc_sz, "NCQ (depth %d/%d)%s", hdepth, | ^~~~~~~~~~~~~~~~~~~~~ drivers/ata/libata-core.c:2378:17: note: ‘snprintf’ output between 16 and 31 bytes into a destination of size 24 2378 | snprintf(desc, desc_sz, "NCQ (depth %d/%d)%s", hdepth, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2379 | ddepth, aa_desc); | ~~~~~~~~~~~~~~~~ Avoid these warnings and the potential truncation by changing the size of the ncq_desc string to 32 characters. Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke Tested-by: Geert Uytterhoeven Reviewed-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/ata/libata-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 0ba0c3d1613f1..6d4dd5e3b58f3 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2366,7 +2366,7 @@ static int ata_dev_config_lba(struct ata_device *dev) { const u16 *id = dev->id; const char *lba_desc; - char ncq_desc[24]; + char ncq_desc[32]; int ret; dev->flags |= ATA_DFLAG_LBA; -- 2.40.1