mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil+cisco@kernel.org>
To: Edward Adam Davis <eadavis@qq.com>
Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	mchehab@kernel.org,
	syzbot+480edd2cadb85ddb4bbe@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH V2] media: dvb-usb: Optimizing err() output
Date: Mon, 3 Nov 2025 12:01:39 +0100	[thread overview]
Message-ID: <9f9d2240-63be-4232-8ad6-44821d2b9177@kernel.org> (raw)
In-Reply-To: <24d04c2c-50b1-48ec-8ba9-c09ef29fd3fd@kernel.org>

Also fix the Subject line to add "pctv452e:" as prefix.

Regards,

	Hans

On 03/11/2025 12:00, Hans Verkuil wrote:
> On 14/10/2025 02:30, Edward Adam Davis wrote:
>> syzbot reported a uninit-value in pctv452e_i2c_msg. [1]
>>
>> When the snd_len or rcv_len check fails and jumps to failed, buf is
>> uninitialized, triggering the uninit-value issue.
>>
>> Setting the err() output buf byte count to 0 before jumping to failed
>> before initializing buf and setting it to 7 after initializing buf avoids
>> this warning.
>>
>> [1]
>> BUG: KMSAN: uninit-value in hex_string+0x681/0x740 lib/vsprintf.c:1220
>>  pctv452e_i2c_msg+0x82a/0x8f0 drivers/media/usb/dvb-usb/pctv452e.c:467
>>  pctv452e_i2c_xfer+0x2e6/0x4c0 drivers/media/usb/dvb-usb/pctv452e.c:502
>>
>> Reported-by: syzbot+480edd2cadb85ddb4bbe@syzkaller.appspotmail.com
>> Closes: https://syzkaller.appspot.com/bug?extid=480edd2cadb85ddb4bbe
>> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
>> ---
>> V1 -> V2: subject typos
>>
>>  drivers/media/usb/dvb-usb/pctv452e.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/usb/dvb-usb/pctv452e.c b/drivers/media/usb/dvb-usb/pctv452e.c
>> index 5094de9a312e..3b6e86a8e9ff 100644
>> --- a/drivers/media/usb/dvb-usb/pctv452e.c
>> +++ b/drivers/media/usb/dvb-usb/pctv452e.c
>> @@ -420,7 +420,7 @@ static int pctv452e_i2c_msg(struct dvb_usb_device *d, u8 addr,
>>  	struct pctv452e_state *state = d->priv;
>>  	u8 *buf;
>>  	u8 id;
>> -	int ret;
>> +	int ret, plen = 0;
> 
> Adding a plen variable isn't the right fix...
> 
>>  
>>  	buf = kmalloc(64, GFP_KERNEL);
>>  	if (!buf)
>> @@ -432,6 +432,7 @@ static int pctv452e_i2c_msg(struct dvb_usb_device *d, u8 addr,
>>  	if (snd_len > 64 - 7 || rcv_len > 64 - 7)
>>  		goto failed;
> 
> ...this check should be moved up to before the kmalloc and just return -EINVAL.
> That also avoids incrementing state->c in that case.
> 
> Regards,
> 
> 	Hans
> 
>>  
>> +	plen = 7;
>>  	buf[0] = SYNC_BYTE_OUT;
>>  	buf[1] = id;
>>  	buf[2] = PCTV_CMD_I2C;
>> @@ -466,7 +467,7 @@ static int pctv452e_i2c_msg(struct dvb_usb_device *d, u8 addr,
>>  failed:
>>  	err("I2C error %d; %02X %02X  %02X %02X %02X -> %*ph",
>>  	     ret, SYNC_BYTE_OUT, id, addr << 1, snd_len, rcv_len,
>> -	     7, buf);
>> +	     plen, buf);
>>  
>>  	kfree(buf);
>>  	return ret;
> 
> 


  reply	other threads:[~2025-11-03 11:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-10  4:19 [syzbot] [media?] KMSAN: uninit-value in pctv452e_i2c_msg syzbot
2025-10-10 15:21 ` [PATCH] meida: dvb-usb: Optimizing err() output Edward Adam Davis
2025-10-14  0:30   ` [PATCH V2] media: " Edward Adam Davis
2025-11-03 11:00     ` Hans Verkuil
2025-11-03 11:01       ` Hans Verkuil [this message]
2025-11-03 11:57         ` [PATCH V3] media: dvb-usb: pctv452e: move snd/rcv len check before kmalloc Edward Adam Davis

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=9f9d2240-63be-4232-8ad6-44821d2b9177@kernel.org \
    --to=hverkuil+cisco@kernel.org \
    --cc=eadavis@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=syzbot+480edd2cadb85ddb4bbe@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /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®