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 4B8E7B67E; Wed, 8 Apr 2026 18:24:45 +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=1775672685; cv=none; b=fo2hN8sCmhqu0/rNENmL9w4J4CFDTkKGeLyDGtA1blAe//gGn8NFiInXrdKrrYq3IQBH4haqA0x7Jyd79jUs2RI+6rLImcPasRs30hwYn/Cre8iB6i7hQLtHKicUY7DpYw7d0A1s85Xi5covsIgszEdhnzsuA0Y7TZ6/39tGXW0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775672685; c=relaxed/simple; bh=SbFBtAtDqZPHB1Qa4Lu7EP3VZO78X8x9Bg7OrHeSkfg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UyVrKhrIAlKhHidEYUaZfSV9mlVVtC5Hm5Dmm++N2BsWc0/Lgz+dnODTrS1yiqSp7L6sibpUDh5yvfWnF1pY/aNBr4OS8JgGLIe9KEeajjspvZcx9fwoPyeJ/pc2q09sYWXkXgP11JF5glF4EZwwWc1/cHrHhHR+Iq4Q5ndZowE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BxlKS5yS; 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="BxlKS5yS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D51B6C19425; Wed, 8 Apr 2026 18:24:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775672685; bh=SbFBtAtDqZPHB1Qa4Lu7EP3VZO78X8x9Bg7OrHeSkfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BxlKS5ySnaiGEW6WPqezOABg0aeRzLejHCqsoRPBc8QXliCuP1YB5piJ3KzTlUjJF 5+M6JADJ1kTqwS1p0cVEjFhllrngW7Fy8lZyE7a5+w8qUZPezLeG5OjDozokHBKDff rDHHezH3uD0oMiNoHHpYHac0BwvHPVEANX40EuS0= 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.6 069/160] hwmon: (tps53679) Fix device ID comparison and printing in tps53676_identify() Date: Wed, 8 Apr 2026 20:02:36 +0200 Message-ID: <20260408175915.781053645@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175913.177092714@linuxfoundation.org> References: <20260408175913.177092714@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.6-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 5c9466244d70d..ecc1be33b3b1b 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