From patchwork Tue Jul 11 09:37:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 13308359 Received: from imap4.hz.codethink.co.uk (imap4.hz.codethink.co.uk [188.40.203.114]) (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 8C569182B3 for ; Tue, 11 Jul 2023 09:37:15 +0000 (UTC) Received: from [134.238.52.102] (helo=rainbowdash) by imap4.hz.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1qJ9o0-00BpMC-Q6; Tue, 11 Jul 2023 10:37:12 +0100 Received: from ben by rainbowdash with local (Exim 4.96) (envelope-from ) id 1qJ9nx-0006AL-2p; Tue, 11 Jul 2023 10:37:09 +0100 From: Ben Dooks To: nvdimm@lists.linux.dev Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, lenb@kernel.org, Ben Dooks Subject: [PATCH v2] ACPI: NFIT: limit string attribute write Date: Tue, 11 Jul 2023 10:37:08 +0100 Message-Id: <20230711093708.23692-1-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If we're writing what could be an arbitrary sized string into an attribute we should probably use sysfs_emit() just to be safe. Most of the other attriubtes are some sort of integer so unlikely to be an issue so not altered at this time. Signed-off-by: Ben Dooks --- v2: - use sysfs_emit() instead of snprintf. --- drivers/acpi/nfit/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 9213b426b125..d7e9d9cd16d2 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -1579,7 +1579,7 @@ static ssize_t id_show(struct device *dev, { struct nfit_mem *nfit_mem = to_nfit_mem(dev); - return sprintf(buf, "%s\n", nfit_mem->id); + return snprintf(buf, PAGE_SIZE, "%s\n", nfit_mem->id); } static DEVICE_ATTR_RO(id);