mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Bence Csókás" <bence98@sch.bme.hu>
To: Johan Hovold <johan@kernel.org>, linux-i2c@vger.kernel.org
Cc: Andi Shyti <andi.shyti@kernel.org>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] i2c: cp2615: fix serial string NULL-deref at probe
Date: Wed, 11 Mar 2026 22:40:19 +0100	[thread overview]
Message-ID: <32f6793c-d728-451d-9e32-35d864fe0035@sch.bme.hu> (raw)
In-Reply-To: <20260309075016.25612-1-johan@kernel.org>

Reviewed-by: Bence Csókás <bence98@sch.bme.hu>

On 3/9/26 08:50, Johan Hovold wrote:
> 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).
> 
> Fixes: 4a7695429ead ("i2c: cp2615: add i2c driver for Silicon Labs' CP2615 Digital Audio Bridge")
> Cc: stable@vger.kernel.org	# 5.13
> Cc: Bence Csókás <bence98@sch.bme.hu>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>   drivers/i2c/busses/i2c-cp2615.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-cp2615.c b/drivers/i2c/busses/i2c-cp2615.c
> index c1dbf7961a02..951de6249834 100644
> --- a/drivers/i2c/busses/i2c-cp2615.c
> +++ b/drivers/i2c/busses/i2c-cp2615.c
> @@ -297,6 +297,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;

I didn't realize at the time I wrote this that `serial` can be NULL, I 
was under the impression that the USB core would pass me an empty string 
if there's no iSerial string descriptor (alas, it does not).
AFAIK real CP2615s will always have a serial, so returning error should 
not be a major problem. However, we could just as easily skip 
`strscpy()` and go on with the probe with an empty name. But I'm fine 
with either solution.

Bence

  reply	other threads:[~2026-03-11 21:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09  7:50 Johan Hovold
2026-03-11 21:40 ` Bence Csókás [this message]
2026-03-12 10:35   ` Johan Hovold
2026-03-19 22:28 ` Andi Shyti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32f6793c-d728-451d-9e32-35d864fe0035@sch.bme.hu \
    --to=bence98@sch.bme.hu \
    --cc=andi.shyti@kernel.org \
    --cc=johan@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®