<feed xmlns='http://www.w3.org/2005/Atom'>
<title>lwn.git/drivers/media/usb/dvb-usb/dw2102.c, branch docs-fixes</title>
<subtitle>Linux kernel documentation tree maintained by Jonathan Corbet</subtitle>
<id>http://mirrors.hust.edu.cn/git/lwn.git/atom?h=docs-fixes</id>
<link rel='self' href='http://mirrors.hust.edu.cn/git/lwn.git/atom?h=docs-fixes'/>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/'/>
<updated>2025-02-21T09:33:12+00:00</updated>
<entry>
<title>media: dvb-usb: Constify struct i2c_algorithm</title>
<updated>2025-02-21T09:33:12+00:00</updated>
<author>
<name>Christophe JAILLET</name>
<email>christophe.jaillet@wanadoo.fr</email>
</author>
<published>2024-09-07T20:36:29+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=fc91d334e045dab1b5f01bd88b4906ad1dfbd223'/>
<id>urn:sha1:fc91d334e045dab1b5f01bd88b4906ad1dfbd223</id>
<content type='text'>
'struct i2c_algorithm' are not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.

More over, dvb_usb_device_properties-&gt;i2c_algo seems to only be copied in
i2c_adapter-&gt;algo, which is already a "const struct i2c_algorithm".
This is done in dvb_usb_i2c_init()

On a x86_64, with allmodconfig, as an example:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  30571	   5916	     36	  36523	   8eab	drivers/media/usb/dvb-usb/af9005.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  30667	   5852	     36	  36555	   8ecb	drivers/media/usb/dvb-usb/af9005.o

Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Signed-off-by: Hans Verkuil &lt;hverkuil@xs4all.nl&gt;
</content>
</entry>
<entry>
<title>media: dvb-usb: Constify struct usb_device_id</title>
<updated>2025-02-21T09:33:08+00:00</updated>
<author>
<name>Christophe JAILLET</name>
<email>christophe.jaillet@wanadoo.fr</email>
</author>
<published>2025-01-05T21:19:57+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=51f76375e3d27177fa211ab653871e5644bcbecb'/>
<id>urn:sha1:51f76375e3d27177fa211ab653871e5644bcbecb</id>
<content type='text'>
'struct usb_device_id' is not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increase overall security.

In order to do that, struct dvb_usb_device_description (in dvb-usb.h) also
needs to be updated.

On a x86_64, with allmodconfig, as an example:
Before:
======
   text	   data	    bss	    dec	    hex	filename
   1983	   4240	      4	   6227	   1853	drivers/media/usb/dvb-usb/a800.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
   2079	   4144	      4	   6227	   1853	drivers/media/usb/dvb-usb/a800.o

Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Signed-off-by: Hans Verkuil &lt;hverkuil@xs4all.nl&gt;
</content>
</entry>
<entry>
<title>media: dw2102: fix a potential buffer overflow</title>
<updated>2024-04-29T18:04:03+00:00</updated>
<author>
<name>Mauro Carvalho Chehab</name>
<email>mchehab@kernel.org</email>
</author>
<published>2024-04-29T14:15:05+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=1c73d0b29d04bf4082e7beb6a508895e118ee30d'/>
<id>urn:sha1:1c73d0b29d04bf4082e7beb6a508895e118ee30d</id>
<content type='text'>
As pointed by smatch:
	 drivers/media/usb/dvb-usb/dw2102.c:802 su3000_i2c_transfer() error: __builtin_memcpy() '&amp;state-&gt;data[4]' too small (64 vs 67)

That seemss to be due to a wrong copy-and-paste.

Fixes: 0e148a522b84 ("media: dw2102: Don't translate i2c read into write")

Reported-by: Hans Verkuil &lt;hverkuil@xs4all.nl&gt;
Reviewed-by: Hans Verkuil &lt;hverkuil@xs4all.nl&gt;
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dw2102: fix coding style issues</title>
<updated>2024-04-29T09:00:17+00:00</updated>
<author>
<name>Mauro Carvalho Chehab</name>
<email>mchehab@kernel.org</email>
</author>
<published>2024-04-29T08:27:51+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=4a7d735191dec9ccaf95f26f63cb6b46fb8cd260'/>
<id>urn:sha1:4a7d735191dec9ccaf95f26f63cb6b46fb8cd260</id>
<content type='text'>
Use checkpatch --strict --in-place to cleanup most style issues.
Then, do some manual work to fix most of the remaining issues.

Signed-off-by: Mauro Carvalho Chehab &lt;mchehab@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dw2102: Fix minor issues</title>
<updated>2024-04-29T08:48:08+00:00</updated>
<author>
<name>Michael Bunk</name>
<email>micha@freedict.org</email>
</author>
<published>2022-01-16T11:22:38+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=efc3e49dc9481ae1c582cd846fc9ecb08535126b'/>
<id>urn:sha1:efc3e49dc9481ae1c582cd846fc9ecb08535126b</id>
<content type='text'>
Found by checkpatch.

Link: https://lore.kernel.org/linux-media/20220116112238.74171-4-micha@freedict.org
Signed-off-by: Michael Bunk &lt;micha@freedict.org&gt;
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dw2102: Dont't list TT Cinergy S2 R4 twice</title>
<updated>2024-04-29T08:48:08+00:00</updated>
<author>
<name>Michael Bunk</name>
<email>micha@freedict.org</email>
</author>
<published>2022-01-16T11:22:37+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=bd693f68cdd66f613aeab480d9d49f6b6b3eee9b'/>
<id>urn:sha1:bd693f68cdd66f613aeab480d9d49f6b6b3eee9b</id>
<content type='text'>
"modinfo dvb-usb-dw2102|grep 0105" returns two lines, because the module
reports this usb alias twice.

Remove one of them.

Signed-off-by: Michael Bunk &lt;micha@freedict.org&gt;
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dw2102: Don't translate i2c read into write</title>
<updated>2024-04-29T08:21:50+00:00</updated>
<author>
<name>Michael Bunk</name>
<email>micha@freedict.org</email>
</author>
<published>2022-01-16T11:22:36+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=0e148a522b8453115038193e19ec7bea71403e4a'/>
<id>urn:sha1:0e148a522b8453115038193e19ec7bea71403e4a</id>
<content type='text'>
The code ignored the I2C_M_RD flag on I2C messages.  Instead it assumed
an i2c transaction with a single message must be a write operation and a
transaction with two messages would be a read operation.

Though this works for the driver code, it leads to problems once the i2c
device is exposed to code not knowing this convention.  For example,
I did "insmod i2c-dev" and issued read requests from userspace, which
were translated into write requests and destroyed the EEPROM of my
device.

So, just check and respect the I2C_M_READ flag, which indicates a read
when set on a message.  If it is absent, it is a write message.

Incidentally, changing from the case statement to a while loop allows
the code to lift the limitation to two i2c messages per transaction.

There are 4 more *_i2c_transfer functions affected by the same behaviour
and limitation that should be fixed in the same way.

Link: https://lore.kernel.org/linux-media/20220116112238.74171-2-micha@freedict.org
Signed-off-by: Michael Bunk &lt;micha@freedict.org&gt;
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dw2102: Fix null-ptr-deref in dw2102_i2c_transfer()</title>
<updated>2023-07-19T10:57:50+00:00</updated>
<author>
<name>Zhang Shurong</name>
<email>zhang_shurong@foxmail.com</email>
</author>
<published>2023-07-08T10:22:52+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=5ae544d94abc8ff77b1b9bf8774def3fa5689b5b'/>
<id>urn:sha1:5ae544d94abc8ff77b1b9bf8774def3fa5689b5b</id>
<content type='text'>
In dw2102_i2c_transfer, msg is controlled by user. When msg[i].buf
is null and msg[i].len is zero, former checks on msg[i].buf would be
passed. Malicious data finally reach dw2102_i2c_transfer. If accessing
msg[i].buf[0] without sanity check, null ptr deref would happen.
We add check on msg[i].len to prevent crash.

Similar commit:
commit 950e252cb469
("[media] dw2102: limit messages to buffer size")

Signed-off-by: Zhang Shurong &lt;zhang_shurong@foxmail.com&gt;
Signed-off-by: Hans Verkuil &lt;hverkuil-cisco@xs4all.nl&gt;
</content>
</entry>
<entry>
<title>media: dw2102: return -EIO instead of -1 for mac address read errors</title>
<updated>2023-05-14T15:05:28+00:00</updated>
<author>
<name>Mauro Carvalho Chehab</name>
<email>mchehab@kernel.org</email>
</author>
<published>2023-05-13T07:04:32+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=b37d9c995aef9487040d07326c9e7e560cf23396'/>
<id>urn:sha1:b37d9c995aef9487040d07326c9e7e560cf23396</id>
<content type='text'>
The dvb-usb core function only checks if the returned value is
zero, so it doesn't actually matter the error code. Still, returning
-1 as an error condition is something that we don't do upstream. So,
change the logic to return -EIO in case of I2C transfer failures.

Signed-off-by: Mauro Carvalho Chehab &lt;mchehab@kernel.org&gt;
</content>
</entry>
<entry>
<title>media: dvb-usb: remove unnecessary (void*) conversions</title>
<updated>2023-05-14T15:05:28+00:00</updated>
<author>
<name>Yu Zhe</name>
<email>yuzhe@nfschina.com</email>
</author>
<published>2023-03-20T06:40:39+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=663e7460b123271c64be7024cadef86dbb4d8463'/>
<id>urn:sha1:663e7460b123271c64be7024cadef86dbb4d8463</id>
<content type='text'>
Pointer variables of void * type do not require type cast.

Link: https://lore.kernel.org/linux-media/20230320064039.5670-1-yuzhe@nfschina.com
Signed-off-by: Yu Zhe &lt;yuzhe@nfschina.com&gt;
Signed-off-by: Mauro Carvalho Chehab &lt;mchehab@kernel.org&gt;
</content>
</entry>
</feed>
