Skip to contentSkip to conversation

USB: legousbtower: use stream_open for stream semantics

PATCH In review [email protected] 3 participants 6 messages Oct 28 – Nov 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: legousbtower: use stream_open for stream semantics

From: Mohammad Shahid <[email protected]>

The LEGO USB Tower driver uses nonseekable_open() in tower_open() However, its read and write have stream semantics.

Use stream_open instead to mark the file as a stream and disable unnecessary file position handling.

The issue is reported by stream_open.cocci script as potential deadlock between read and write operation.

---
 drivers/usb/misc/legousbtower.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/legousbtower.c +1 -1
index 18dd4115befb..b849bd0e9664 100644
@@ -313,7 +313,7 @@ static int tower_open(struct inode *inode, struct file *file)
 	struct tower_reset_reply reset_reply;
 	int result;
 
-	nonseekable_open(inode, file);
+	stream_open(inode, file);
 	subminor = iminor(inode);
 
 	interface = usb_find_interface(&tower_driver, subminor);
Signature · 1 line
2.43.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines

From: Mohammad Shahid <[email protected]>

The LEGO USB Tower driver uses nonseekable_open() in tower_open() However, its read and write have stream semantics.

Quoted 7 lines

Use stream_open instead to mark the file as a stream and disable unnecessary file position handling.

The issue is reported by stream_open.cocci script as potential deadlock between read and write operation.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to [email protected]

Hi,

Could you please review patch and give your feedback,when time permits.

Thanks
Shahid.

Quoted 33 lines · On 2026-10-28 23:58 +0530, [email protected] wrote:

From: Mohammad Shahid <[email protected]>

The LEGO USB Tower driver uses nonseekable_open() in tower_open() However, its read and write have stream semantics.

Use stream_open instead to mark the file as a stream and disable unnecessary file position handling.

The issue is reported by stream_open.cocci script as potential deadlock between read and write operation.

---
 drivers/usb/misc/legousbtower.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/misc/legousbtower.c +1 -1
index 18dd4115befb..b849bd0e9664 100644
@@ -313,7 +313,7 @@ static int tower_open(struct inode *inode, struct file *file)
 	struct tower_reset_reply reset_reply;
 	int result;
 
-	nonseekable_open(inode, file);
+	stream_open(inode, file);
 	subminor = iminor(inode);
 
 	interface = usb_find_interface(&tower_driver, subminor);
Signature · 1 line
2.43.0
maintainer
#3 lore raw
Quoted 23 lines · On Tue, Nov 10, 2026 at 11:01:36PM +0530, [email protected] wrote:

Hi,

Could you please review patch and give your feedback,when time permits.

Thanks
Shahid.

Quoted 15 lines · On 2026-10-28 23:58 +0530, [email protected] wrote:

From: Mohammad Shahid <[email protected]>

The LEGO USB Tower driver uses nonseekable_open() in tower_open() However, its read and write have stream semantics.

Use stream_open instead to mark the file as a stream and disable unnecessary file position handling.

The issue is reported by stream_open.cocci script as potential deadlock between read and write operation.

---
 drivers/usb/misc/legousbtower.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

How was this tested?

#4 lore raw

Hi Greg,

I did basic sanity ,I build driver and ran smatch after changes.

I don't have Lego USB HW to test it ,but there is similar changes in Xyllibus ,that was sent by me and Eli(maintainer)has tested in HW. According to Eli ,There is no regressions with stream_open().

Here is discussion:
https://lore.kernel.org/all/[email protected]/

Thanks
Shahid.

Quoted 28 lines · Greg KH
Quoted 23 lines · On Tue, Nov 10, 2026 at 11:01:36PM +0530, [email protected] wrote:

Hi,

Could you please review patch and give your feedback,when time permits.

Thanks
Shahid.

Quoted 15 lines · On 2026-10-28 23:58 +0530, [email protected] wrote:

From: Mohammad Shahid <[email protected]>

The LEGO USB Tower driver uses nonseekable_open() in tower_open() However, its read and write have stream semantics.

Use stream_open instead to mark the file as a stream and disable unnecessary file position handling.

The issue is reported by stream_open.cocci script as potential deadlock between read and write operation.

---
 drivers/usb/misc/legousbtower.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

How was this tested?

maintainer
#5 lore raw
Quoted 3 lines · On Wed, Nov 11, 2026 at 06:30:21PM +0530, [email protected] wrote:

Hi Greg,

I did basic sanity ,I build driver and ran smatch after changes.

So, no testing :)

Quoted 6 lines

I don't have Lego USB HW to test it ,but there is similar changes in Xyllibus ,that was sent by me and Eli(maintainer)has tested in HW. According to Eli ,There is no regressions with stream_open().

Here is discussion:
https://lore.kernel.org/all/[email protected]/

If you don't have this hardware, then there's no rush on this potential change.

thanks,

greg k-h