From mboxrd@z Thu Jan 1 00:00:00 1970 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 5900CB67E; Wed, 8 Apr 2026 18:16:38 +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=1775672198; cv=none; b=Qz6qLn5RT5pfgWKGXIUQ5wdXf1Ji/tnKQT5uxNaCdlNuV7cMd1Y0r5knuoHVSKwGEJV/AajzA9Ud68FX5UY0vU3hgQGgOjoRM1wW90tN6h/izTcLt1xrwRm0Ey7tng076OQOwcZQLGHde39K9aMLkUt9E/m2Z+dMz1lJNynVEJo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775672198; c=relaxed/simple; bh=QvOdEm+NppoxKeynJYTGn1qQO70XHgRvdChI/wKQEg8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dJU6mOmjceU69ue9MvViAq8DDAN7alZe2p5q5jiNYPOUyJeMaRab4ZBgYG6dExYdTzSuyZ0+mktMeBSJPkvbY+aUIxKHAAVd1QBt4SyOcFCGA85x9FVPZ57FP3js3mwYiCGSvHd2mkxRQBlaOTprCQvZTtUOh1sc3OXvsqD2iIU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2abcYfCp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2abcYfCp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E23D9C19421; Wed, 8 Apr 2026 18:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775672198; bh=QvOdEm+NppoxKeynJYTGn1qQO70XHgRvdChI/wKQEg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2abcYfCpYp2VbS5etDNWUsE/RQ3C1BBGXETi9F8TOD3YWpvI69pO6SAyLM+UAvTQb +57aeaHy1hriURsbK5o7CwlAx8OL8/TlEFE7hIP3UfmpPuGp17G7dN28VbjvWY+XDV QNKLWE7OyQei1ev8Yqx2UEfiGXbBqjxBTvT/WzF0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sanman Pradhan , Guenter Roeck , Sasha Levin Subject: [PATCH 6.1 195/312] hwmon: (tps53679) Fix device ID comparison and printing in tps53676_identify() Date: Wed, 8 Apr 2026 20:01:52 +0200 Message-ID: <20260408175941.041486419@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175933.715315542@linuxfoundation.org> References: <20260408175933.715315542@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sanman Pradhan [ Upstream commit ca34ee6d0307a0b4e52c870dfc1bb8a3c3eb956e ] tps53676_identify() uses strncmp() to compare the device ID buffer against a byte sequence containing embedded non-printable bytes (\x53\x67\x60). strncmp() is semantically wrong for binary data comparison; use memcmp() instead. Additionally, the buffer from i2c_smbus_read_block_data() is not NUL-terminated, so printing it with "%s" in the error path is undefined behavior and may read past the buffer. Use "%*ph" to hex-dump the actual bytes returned. Per the datasheet, the expected device ID is the 6-byte sequence 54 49 53 67 60 00 ("TI\x53\x67\x60\x00"), so compare all 6 bytes including the trailing NUL. Fixes: cb3d37b59012 ("hwmon: (pmbus/tps53679) Add support for TI TPS53676") Signed-off-by: Sanman Pradhan Link: https://lore.kernel.org/r/20260330155618.77403-1-sanman.pradhan@hpe.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/hwmon/pmbus/tps53679.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/pmbus/tps53679.c b/drivers/hwmon/pmbus/tps53679.c index 81b9d813655ad..de91996886dbb 100644 --- a/drivers/hwmon/pmbus/tps53679.c +++ b/drivers/hwmon/pmbus/tps53679.c @@ -156,8 +156,8 @@ static int tps53676_identify(struct i2c_client *client, ret = i2c_smbus_read_block_data(client, PMBUS_IC_DEVICE_ID, buf); if (ret < 0) return ret; - if (strncmp("TI\x53\x67\x60", buf, 5)) { - dev_err(&client->dev, "Unexpected device ID: %s\n", buf); + if (ret != 6 || memcmp(buf, "TI\x53\x67\x60\x00", 6)) { + dev_err(&client->dev, "Unexpected device ID: %*ph\n", ret, buf); return -ENODEV; } -- 2.53.0