FAILED: patch "[PATCH] i2c: cp2615: fix serial string NULL-deref at probe" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x aa79f996eb41e95aed85a1bd7f56bcd6a3842008
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026032348-endanger-humvee-fc57@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From aa79f996eb41e95aed85a1bd7f56bcd6a3842008 Mon Sep 17 00:00:00 2001
From: Johan Hovold <[email protected]>
Date: Mon, 9 Mar 2026 08:50:16 +0100
Subject: [PATCH] i2c: cp2615: fix serial string NULL-deref at probe
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The cp2615 driver uses the USB device serial string as the i2c adapter name but does not make sure that the string exists.
Verify that the device has a serial number before accessing it to avoid triggering a NULL-pointer dereference (e.g. with malicious devices).
drivers/i2c/busses/i2c-cp2615.c +3 -0
@@ -298,6 +298,9 @@ cp2615_i2c_probe(struct usb_interface *usbif, const struct usb_device_id *id)if (!adap)return -ENOMEM ; +if (!usbdev->serial) +return -EINVAL ; +strscpy (adap->name, usbdev->serial,sizeof (adap->name)); adap->owner =THIS_MODULE ; adap->dev.parent = &usbif->dev;
Sasha Levin
maintainerPATCH 1/2 i2c: cp2615: replace deprecated strncpy with strscpy
From: Justin Stitt <[email protected]>
[ Upstream commit e2def33f9ee1b1a8cda4ec5cde69840b5708f068 ]
strncpy is deprecated for use on NUL-terminated destination strings [1].
We should prefer more robust and less ambiguous string interfaces.
We expect name to be NUL-terminated based on its numerous uses with functions that expect NUL-terminated strings.
For example in i2c-core-base.c +1533:
| dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
NUL-padding is not required as adap is already zero-alloacted with:
| adap = devm_kzalloc(&usbif->dev, sizeof(struct i2c_adapter), GFP_KERNEL);
With the above in mind, a suitable replacement is strscpy [2] due to the fact that it guarantees NUL-termination on the destination buffer without unnecessarily NUL-padding.
Stable-dep-of: aa79f996eb41 ("i2c: cp2615: fix serial string NULL-deref at probe")
--- drivers/i2c/busses/i2c-cp2615.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-cp2615.c +1 -1
@@ -298,7 +298,7 @@ cp2615_i2c_probe(struct usb_interface *usbif, const struct usb_device_id *id)if (!adap)return -ENOMEM ; -strncpy (adap->name, usbdev->serial,sizeof (adap->name) -1 ); +strscpy (adap->name, usbdev->serial,sizeof (adap->name)); adap->owner =THIS_MODULE ; adap->dev.parent = &usbif->dev; adap->dev.of_node = usbif->dev.of_node;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 2/2 i2c: cp2615: fix serial string NULL-deref at probe
From: Johan Hovold <[email protected]>
[ Upstream commit aa79f996eb41e95aed85a1bd7f56bcd6a3842008 ]
The cp2615 driver uses the USB device serial string as the i2c adapter name but does not make sure that the string exists.
Verify that the device has a serial number before accessing it to avoid triggering a NULL-pointer dereference (e.g. with malicious devices).
--- drivers/i2c/busses/i2c-cp2615.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/i2c/busses/i2c-cp2615.c +3 -0
@@ -298,6 +298,9 @@ cp2615_i2c_probe(struct usb_interface *usbif, const struct usb_device_id *id)if (!adap)return -ENOMEM ; +if (!usbdev->serial) +return -EINVAL ; +strscpy (adap->name, usbdev->serial,sizeof (adap->name)); adap->owner =THIS_MODULE ; adap->dev.parent = &usbif->dev;
Signature · 1 line
2.51.0