From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6157E37B036 for ; Sun, 26 Jul 2026 07:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785050529; cv=none; b=qDBwfoxSa0DPf/OJRe/brl3ylaTpn344gCvzOyY+OH+Pmt3J06nGoMigDRV4viNVk4k2/9bYppC1SD/F8DmeOejM99adgQn5UcJrQBQB5k038p2RWNh/TdVAalIUirCql7o+22iId8QG0y8tR6VhC9AW7CJsAv6+r9xIIqQoFUU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785050529; c=relaxed/simple; bh=VZCjoqNfIq3fo0Vu4oS3PYyaH8ZyzB/jpp558LfhArU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EkWB7ZbTl2STO0AxGA83hus8vfPuK/fFTfiRb0JiKkOqjIqlQOEO1WR9Ck12CW9GVWnKWnCMxGYcm3wxHITVwk7D6DBTpepKVQD3V1EdNr8BhLZ1c/kogGGAaY8tYZlTJePXZR81nIE0bs/K51UzI399m11ScOyYanxzlUqYZ/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Kzr5k7sa; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Kzr5k7sa" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-3856d6fbcb3so1213591a91.2 for ; Sun, 26 Jul 2026 00:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785050528; x=1785655328; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=l0dbtxwZelwgBLjGWlT9BwYMPJVsVlDkZBf3ZnPfbRw=; b=Kzr5k7saDl8DiZ2Dd53XlznkMLHfUaXpgwhtUrcV5G+Df9D4vMTTIinZL4KR5jHnpM KdAF4ngR4I53BEA9vUiCC4KG5HKEkCpPO6JOmcYIF1XN12+vl2J1LnMkgiaCWGQ20y6t WzAGwHojhEMXAMkYJBrSv86q3LSmgeiVstiOfM87S4FyHz3t4MRlIwvO/rNp2y6N0bcD uaD6VjJD5yj4x1BhDbX/AtOLv4cLkv+WAOj3s843r+YzSNV95cZ+1oINrY7vsCOmXjf6 6RQsmr7yeLiv+l49cw54oRYY7vofE9lhnm5UAB84qoWzhsCe9f/D2ah3OenPbNUhQiWc N2+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785050528; x=1785655328; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=l0dbtxwZelwgBLjGWlT9BwYMPJVsVlDkZBf3ZnPfbRw=; b=ffss/50uEkyd3m3R1Jego9r+tOTMb9ucvxrXT2L8bsiZzUB/wZ4BMHVbUHR6/sIUIo 0bLkiHkiytYd57O694zOQExnOcjqtJnkucMkJMe9ZsbMm4NsAurvOheLqmBzYF+gaYEn zothxSpU7oYJd6r2T0a/OjPe4EwEbkwCwlHRtZq/RCdRPpyCcBvWcoiAEkzQYPF1y5ND bFCJUAMGa2wl5Lju8fTZZ8L97CtdyJy47FZRp5C5xY9GWo8BDk169zn08gCye0dBTV8D Eqxd1as172WRy3S1qxXiAT3VquePwFD2baCEthx8wvCa1DzY5ZtQu9aL5TK3dNIce8e6 5ZLg== X-Forwarded-Encrypted: i=1; AHgh+RqWfECUQF9T6T5GKT/jjrRCBV7HHah+rA82ew8JRsQsXB13D6nZY4OlBh871AOJsNeUbPIFMPFoGx609O4=@vger.kernel.org X-Gm-Message-State: AOJu0YzygdBlE1cyD2ElVjVoWI0afpqizMBv+OsLml15k5VDvEuG1ONN 8z6l7D75YTcMgvMiShxfZOT65ezfxPynqLO0fOoiWSZRZ4+C3BeMfmOSuYfjqFqxXT0= X-Gm-Gg: AR+sD13+EqPItQ/Vl0azUkQ18R4lBue9tw1+s7wm3PWBA00J885i47vhPgVYQ0s0d0Q Ug5C5fFdi2SiQnB+HG9JEbtSl/SfrNOs6XZv/U/SZgIqYIDHgyE4ZMhnC2Qw3ehYHq4FXo6dauc 9ycR2XD41mwIJi9ZyxoXCuMPl8TIV3ATG8/tqlbFwNbk+otg4cA67Xl2aztcx6s2sAWR8AJ2a2Z Qk4Pl+oATBV6S4wSAA+4sHraSCLmu59+LUmkCc+VbL3KZqIwJV4Qgrb93cIcwJQIVko67XBbcAS Rg9Co7VRmGeJn+hn39EcSIUYe5/GtYQwnr//5P1Ktyo936q1CXo+cP11z0nFbB6wuEqyVOAte6Q G9AQ6Qzq28LStVMYdpwYDV1XaFX6fcf1jk47Xt4yGPXR13G/hlgNXOJNzzW82kAGN3aFJYQBhDs PYug== X-Received: by 2002:a17:90b:57e3:b0:38e:9279:468c with SMTP id 98e67ed59e1d1-38f296091e5mr4291056a91.25.1785050527598; Sun, 26 Jul 2026 00:22:07 -0700 (PDT) Received: from kdev.. ([108.180.130.139]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38f294e1ab1sm1489074a91.10.2026.07.26.00.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2026 00:22:07 -0700 (PDT) From: Babanpreet Singh To: Sebastian Reichel Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Babanpreet Singh Subject: [PATCH 0/2] power: supply: sbs-battery: Fix the shared serial number buffer Date: Sun, 26 Jul 2026 07:22:04 +0000 Message-ID: <20260726072206.7-1-bbnpreetsingh@gmail.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The serial number of every sbs-battery instance is formatted into one file-scope buffer, so concurrent reads on two batteries can make one battery report the other's serial number. Patch 1 gives each device its own buffer. While rewriting that sprintf() call it became apparent that the conversion is also the only W=1 warning in this driver: the value is carried in an int and only its negative half is rejected, so gcc cannot prove that four hex digits fit the five-byte buffer. Patch 2 casts to the register's actual width. It is a separate patch because it is a distinct (and purely cosmetic) change - please just drop it if you would rather not carry it. Both patches are compile-tested only; I have no SBS hardware. The race in patch 1 was derived from the code, not observed on a running system. Detail on the multi-instance premise for patch 1, since it is the part that matters: sbs-battery binds per I2C client and sbs-manager registers one muxed I2C channel per supported battery precisely so that the smart battery driver can be bound to each of them (MANAGER_SBS Kconfig help says as much), so more than one instance is a supported configuration rather than a hypothetical one. Babanpreet Singh (2): power: supply: sbs-battery: Use a per-device serial number buffer power: supply: sbs-battery: Bound the serial number conversion to 16 bits drivers/power/supply/sbs-battery.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.43.0