Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp184385lqp; Fri, 12 Apr 2024 14:33:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaPDd0uCmUhXW8uRSJsQ85Tq5X8CJuHXrIL7ztcea09EJmPUn3558lbPd9y3u0QwyZqx0E5rb67n+yKDGXtv6WMbPckIaVm1jNopBTBw== X-Google-Smtp-Source: AGHT+IFrHpaSwYhAbC2fRKSKZdoFQOLe76HSaj/9djGVqWmHIxwvVCCJi3vw9EaXaZ0fook9FhVW X-Received: by 2002:a05:6a21:191:b0:1a3:b155:1cd6 with SMTP id le17-20020a056a21019100b001a3b1551cd6mr4950117pzb.8.1712957617386; Fri, 12 Apr 2024 14:33:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712957617; cv=pass; d=google.com; s=arc-20160816; b=wArJRUx5Jk1/S7ozdbPdbLW6UA/tEWwjI+FdVyHlUkNQ+ew5kvVW+JUx8/nCAV8t+V 2i8WgGvdmmxGxmZd5ZOAzDOCOF+AOgpNaXmJv4uWemR7BxUL/o2vhiarYH2V4VKWStTK ZlFh1Q+v1WUBexUTT4Y90FaC15MGpzRshmrzpaTLq5wmKC74MQ2kJDs+sNlAVKFNRPP3 hOXnxmV9+iMJJmw5LOmeGQH8HdzfFV+nfvYPf4QTUrlOGn6grtO9jqySayby9lTz3GVz b2aYsHTujDRH+GO3ndlyvdYDvOG7iqmxSwLSkt+Mk7tGLoGl/Y3dUfsX6NtrncuCO4Ik X+KQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:subject:cc:to:from:date:dkim-signature; bh=3uA9JmoHaKFlWjXORH+Tr5K9M/WCaEUasVn/wVi/1Bs=; fh=mRaMVpah1O9mIbctKWG/SR0HzUq7kE6xzc0VDH8nX5U=; b=i4bOck6UDXdIHM9wc2x1SxyXtTXLZm2FY9/cR/5fnA0AMqK53mCqTeyZ0ymTGKOM2e yTgMLewvKtEQvBvZ3s4TdoUS5FT32+GgzLqVJ1rqZK49XfBvGmWj9a5nPPsepR25Jzk9 zAvorqdoek00jy+w7shGdDDf4pZo+mlzX72eClTiJ/qmk9Wju0mZ0aY1P50MJslOsM+v zW+tM3bnzM5OC3ZDaAJogjJvnVn8VqUgi2ymaDFlSi+vf7/WAu3bd8lYoyWO4grHJqPi Tg8fTf1n2JAIzbSK1+8ztrZQ0BwN+BnsuRO6Dv7hfyZaRCaXpCoOV6BoRTx3zp/jS+Ba e1aA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HhSTbhDx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-143386-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143386-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id p39-20020a056a000a2700b006ed189a99f1si4248920pfh.345.2024.04.12.14.33.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 14:33:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-143386-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HhSTbhDx; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-143386-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-143386-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0A061280A82 for ; Fri, 12 Apr 2024 21:33:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A949152180; Fri, 12 Apr 2024 21:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HhSTbhDx" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61815610B; Fri, 12 Apr 2024 21:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712957610; cv=none; b=gYtMhdqm+FIZJZxhh4Y/v6yCxVfEmgUXfanti8upPkwTuqeqYZk9nEruH1qKUjXbLKgXbenuqpPW/LjV5W7thDhAzGD+GfUF7plDI2+kFNU5GfxO/K4wtfve6jbUjZr6g4LOjp4tRRCxjj2zeGUXZA2NOYA/sgTeF+zGerihXws= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712957610; c=relaxed/simple; bh=CtC3I2fZQ9mZwBg/TkYlfnfS9MFN0gpK2lQ696PJfG4=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=tDQpeCxcWK26FT8E/UshpxRx62RGr569tdfLVb2VxPr0bCyItzEXD3JrDIrsiVwLQ/p7LZs5YYhOduw5/UbExUplo80ZKYQVgXkAsUdhwcvc8HOwQJb+11eHfAm0dhMZ6HrsimcRzYc87eogRGTxkzs78Q6Vr4FpUAqqB0jUXJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HhSTbhDx; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9BF3C113CC; Fri, 12 Apr 2024 21:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712957610; bh=CtC3I2fZQ9mZwBg/TkYlfnfS9MFN0gpK2lQ696PJfG4=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=HhSTbhDx+UWURLfC7hyj8yyHFrTuSDmbdVUCnommqoKxlUxohFWXZfu8zZy4uL+oO bNexmE9vPvhh3q/VdkYgk2zTi8NtvrRth2hbv4WSvNwDnvWnHiL6HQHAqzOScatefn noUtbdiM9PKpxBqMmC54oC5bUgu6mS6n7Nymk9BuYWJpVfJA8IVYmXtfTf6K5TOMhY CgM5RxS+q4mYVevj/nkmA1h/yhdDDT8DLjh5RwT08wbD4zgEjI7UpoFsTEAdUX6jwg n2GnhytXq2vfNm19rt+JkfOe4dU4zR3CEpSCIRp/oXtCfaN3RNJrF/rv2x8tS4Tyc6 1tWYqreRv2HUw== Date: Fri, 12 Apr 2024 16:33:28 -0500 From: Bjorn Helgaas To: Sergio Paracuellos Cc: linux-pci@vger.kernel.org, bhelgaas@google.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PCI: mt7621: Fix possible string truncation in snprintf Message-ID: <20240412213328.GA19361@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240111082704.2259450-1-sergio.paracuellos@gmail.com> On Thu, Jan 11, 2024 at 09:27:04AM +0100, Sergio Paracuellos wrote: > The following warning appears when driver is compiled with W=1. > > CC drivers/pci/controller/pcie-mt7621.o > drivers/pci/controller/pcie-mt7621.c: In function ‘mt7621_pcie_probe’: > drivers/pci/controller/pcie-mt7621.c:228:49: error: ‘snprintf’ output may > be truncated before the last format character [-Werror=format-truncation=] > 228 | snprintf(name, sizeof(name), "pcie-phy%d", slot); > | ^ > drivers/pci/controller/pcie-mt7621.c:228:9: note: ‘snprintf’ output between > 10 and 11 bytes into a destination of size 10 > 228 | snprintf(name, sizeof(name), "pcie-phy%d", slot); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Clean this up increasing destination buffer one byte. > > Reported-by: Bjorn Helgaas > Closes: https://lore.kernel.org/linux-pci/20240110212302.GA2123146@bhelgaas/T/#t > Signed-off-by: Sergio Paracuellos Krzysztof applied this to pci/controller/mt7621 for v6.10, thanks! I just pulled that branch into "next", so it should appear in the next linux-next. > --- > drivers/pci/controller/pcie-mt7621.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/pcie-mt7621.c b/drivers/pci/controller/pcie-mt7621.c > index 79e225edb42a..d97b956e6e57 100644 > --- a/drivers/pci/controller/pcie-mt7621.c > +++ b/drivers/pci/controller/pcie-mt7621.c > @@ -202,7 +202,7 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie, > struct mt7621_pcie_port *port; > struct device *dev = pcie->dev; > struct platform_device *pdev = to_platform_device(dev); > - char name[10]; > + char name[11]; > int err; > > port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); > -- > 2.25.1 >