Re: [PATCH] usb-storage: alauda: track media_initialized per port

From: Alan Stern

Date: Sat Nov 21 2026 - 15:55:06 EST


On Sat, Nov 21, 2026 at 10:19:56PM +0500, Arbab Haider wrote:
> Commit 16637fea001a ("usb-storage: alauda: Check whether the media is
> initialized") added a media_initialized flag to struct alauda_info to
> prevent divide-by-zero errors when alauda_init_media() has not succeeded.
>
> However, Alauda devices expose two LUNs (us->max_lun = 1) backed by
> info->port[0] (xD) and info->port[1] (SmartMedia). Storing
> media_initialized in struct alauda_info shares it across both ports: once
> port 0 initializes, media_initialized becomes true, allowing port 1 to
> skip alauda_init_media() when its media-change bit is clear and divide by
> port[1].uzonesize == 0 in alauda_read_data() or alauda_write_lba():
>
> Oops: divide error: 0000 [#1] SMP KASAN NOPTI
> RIP: 0010:alauda_read_data drivers/usb/storage/alauda.c:953 [inline]
> RIP: 0010:alauda_transport+0xe5a/0x35c0 drivers/usb/storage/alauda.c:1187
>
> Additionally, alauda_check_media() never cleared media_initialized when
> media was removed or before re-initializing on media change, leaving it
> true if a subsequent re-initialization failed.
>
> Move media_initialized into struct alauda_media_info so each port tracks
> its own initialization state, and clear it when media is absent or before
> re-initializing on media change.
>
> Reported-by: syzbot+dc208a8cf8d37cf3e5ac@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://syzkaller.appspot.com/bug?extid=dc208a8cf8d37cf3e5ac
> Fixes: 16637fea001a ("usb-storage: alauda: Check whether the media is initialized")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Arbab Haider <arbabhaider649@xxxxxxxxx>
> ---

Has this patch been tested?

Alan Stern