Message ID | 20230725052925.1712680-1-sunilvl@ventanamicro.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp2254018vqg; Mon, 24 Jul 2023 22:43:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlENC6l2O4Li/XLvg0HYBVq3yLwvphUKhwLddJ7L3UIBztc7ef6DD5vD7UoLkuMGtcFyvsJ2 X-Received: by 2002:a17:906:209d:b0:99b:56f1:300d with SMTP id 29-20020a170906209d00b0099b56f1300dmr11638490ejq.69.1690263818809; Mon, 24 Jul 2023 22:43:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690263818; cv=none; d=google.com; s=arc-20160816; b=Ijr44HxUMJLRkm/iDpmF7vkN7ex57W5kM9ZPQX3PDPqcNKhoY2XkdsMv52UDaYGPn1 ocuUbQcDUUQqGkMkEp2EVqkdAxGPdn2exyrOEXKcIVWGnsfLo4P3snxdHtokXP3hN39x u8YdkLGyv+IjIxMzgObvjQb21fxDPj0xWDvTTB6fH5ao5djC6ioO3DxvEg70ydKpFicX vSkKm/ll2/FS8z1G3R+xywAT/wTcHHzKUs7wy0q9JaXm+CX51gktGC8HvUDFjOeSZSP/ dong60VF/E4xFBMVyaNoWtJ/w5rnn6ZmsgjOt4h+d5+Rd0wQqI3aJMxSLeEDYP4ajce/ HZiw== 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=JffUwG5326xuKPzlEojNAz+P0KswaZOylMYMK9oigVI=; fh=eaSLqPW1tYJLcGe1fEbLiKDsOlfcsoDLlfvx68HmMhA=; b=RQ7sGC8M55H9JD6051/4pokcRaV+VYdzBDQiZ80DC9FILpEMA2mTl7wDg4unNQPKJV aJ8szV/+B90rfYaetfDz6VyRkmDm4KaAvTrZ3/XCHCyTB88ZUc4Es0IJZ7cRrjTet4uZ /DUkqgAP98sQjnxJARYIBhsj/VRxgaDH9AFqAYLZt41CETaKa6ieRgSxzXcFgdqQPONG NukAqbPIsryWn9XHx/ScxEm3KN9PEP1jXZV0ImJTlytGXYWSA7LqT8sLajek7/o48ZuP AQ8rV+i9hGsrGpzmMucMDLnSwVuVxUTOy98AmgbCDDXdXg7tF/oOhC6MFSjFWVOdP9Ec UHxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=Puoaq6Ml; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h9-20020a17090619c900b00992e51fe33bsi7838597ejd.118.2023.07.24.22.43.14; Mon, 24 Jul 2023 22:43:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=Puoaq6Ml; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230408AbjGYF3j (ORCPT <rfc822;kloczko.tomasz@gmail.com> + 99 others); Tue, 25 Jul 2023 01:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230339AbjGYF3h (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 25 Jul 2023 01:29:37 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61E93E4D for <linux-kernel@vger.kernel.org>; Mon, 24 Jul 2023 22:29:36 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-666ed230c81so4837602b3a.0 for <linux-kernel@vger.kernel.org>; Mon, 24 Jul 2023 22:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1690262976; x=1690867776; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JffUwG5326xuKPzlEojNAz+P0KswaZOylMYMK9oigVI=; b=Puoaq6MlxKFy+9BHEaSqKQsnkMf3TZh+ZHQCggaH7fm0vvocL/n5gTMYzOzB4XlBTH 7eScle8E3XsXUwItonwl3oZfT5EGkPq4deDf2fmEYSZ1qvI3F6TTCAgizR+aHfNJOaOW zJy7xZhu4AVdfqBRg+4l6BzpXPaYKYJtbbEiFYjeewtsNHiOK1MgPyG5jIwgGbX3MxDp C6BaKpqCxfcrAUv0C+M729VVUam8g3JB+Wcg7A7kH+bCILSsCEshrcvZejys5KFUCNrP Qwy9tQqxZSvPLew8hXVjBogQ0R3/PJi+o8Qt5A6h6xe0XbGPX+Gr99ifiL+vtFTCxWJu WD2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690262976; x=1690867776; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JffUwG5326xuKPzlEojNAz+P0KswaZOylMYMK9oigVI=; b=ah4l/BS9ZSlEOy0h6EHrgmZkA3dm6l3RMjSUg4hMKZAzBzPMqAh4mTLcykNnbSz9Ho VX4GRL6Sw/qKjaP/85QIbyw/m8nmow2NC6uiztB0QLo4i7789TO3wss6AxuixkOWQ5k9 NfFFgcsUiTUnvq5k1kFKhvyMwY8c3hO9c/i0oDAP+gGPknnQ6Sc884AU9j/1uipk13jQ wEfKmLoQW6AmqeCEtq57Yv5JuoFp4YxRU88rgsVbDR49mqz9eh3l439z3HQUoqEcdt6e 7ck3CTKTU8bOFWHAezodV2ZYyctLDnH7eKfb4U+7SLHaGmnfFucSjSDmwXxDQSt29bWb 02wg== X-Gm-Message-State: ABy/qLYHGyVqxa/BZ9svm/f3Ztecft57+r4AmuEeg8BMY3TOpoi6g5wl SstzseB4ivCVAD5Ft1U/31PC7g== X-Received: by 2002:a05:6a00:1148:b0:641:3bf8:6514 with SMTP id b8-20020a056a00114800b006413bf86514mr12784986pfm.10.1690262975805; Mon, 24 Jul 2023 22:29:35 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.190.25]) by smtp.gmail.com with ESMTPSA id r6-20020a62e406000000b00684b64da08bsm8634597pfh.132.2023.07.24.22.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 22:29:35 -0700 (PDT) From: Sunil V L <sunilvl@ventanamicro.com> To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Rafael J . Wysocki" <rafael@kernel.org>, Len Brown <lenb@kernel.org>, Palmer Dabbelt <palmer@rivosinc.com>, Andrew Jones <ajones@ventanamicro.com>, Conor Dooley <conor.dooley@microchip.com>, Sunil V L <sunilvl@ventanamicro.com>, kernel test robot <lkp@intel.com> Subject: [PATCH] PNP/ACPI: Fix string truncation warning Date: Tue, 25 Jul 2023 10:59:25 +0530 Message-Id: <20230725052925.1712680-1-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772370074040018537 X-GMAIL-MSGID: 1772370074040018537 |
Series |
PNP/ACPI: Fix string truncation warning
|
|
Commit Message
Sunil V L
July 25, 2023, 5:29 a.m. UTC
LKP reports below warning when building for RISC-V.
drivers/pnp/pnpacpi/core.c:253:17:
warning: 'strncpy' specified bound 50 equals destination
size [-Wstringop-truncation]
This appears like a valid issue since the destination
string may not be null-terminated. To fix this, append
the NUL explicitly after the strncpy.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202307241942.Rff2Nri5-lkp@intel.com/
Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
---
drivers/pnp/pnpacpi/core.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On Tue, Jul 25, 2023 at 7:29 AM Sunil V L <sunilvl@ventanamicro.com> wrote: > > LKP reports below warning when building for RISC-V. > > drivers/pnp/pnpacpi/core.c:253:17: > warning: 'strncpy' specified bound 50 equals destination > size [-Wstringop-truncation] > > This appears like a valid issue since the destination > string may not be null-terminated. To fix this, append > the NUL explicitly after the strncpy. > > Reported-by: kernel test robot <lkp@intel.com> > Closes: https://lore.kernel.org/oe-kbuild-all/202307241942.Rff2Nri5-lkp@intel.com/ > Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> > --- > drivers/pnp/pnpacpi/core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c > index 38928ff7472b..6ab272c84b7b 100644 > --- a/drivers/pnp/pnpacpi/core.c > +++ b/drivers/pnp/pnpacpi/core.c > @@ -254,6 +254,9 @@ static int __init pnpacpi_add_device(struct acpi_device *device) > else > strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name)); > > + /* Handle possible string truncation */ > + dev->name[sizeof(dev->name) - 1] = '\0'; > + > if (dev->active) > pnpacpi_parse_allocated_resource(dev); > > -- Applied as 6.6 material, thanks!
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 38928ff7472b..6ab272c84b7b 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -254,6 +254,9 @@ static int __init pnpacpi_add_device(struct acpi_device *device) else strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name)); + /* Handle possible string truncation */ + dev->name[sizeof(dev->name) - 1] = '\0'; + if (dev->active) pnpacpi_parse_allocated_resource(dev);