hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/usb/storage/alauda.c
....@@ -318,7 +318,8 @@
318318 rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe,
319319 command, 0xc0, 0, 1, data, 2);
320320
321
- usb_stor_dbg(us, "Media status %02X %02X\n", data[0], data[1]);
321
+ if (rc == USB_STOR_XFER_GOOD)
322
+ usb_stor_dbg(us, "Media status %02X %02X\n", data[0], data[1]);
322323
323324 return rc;
324325 }
....@@ -438,6 +439,8 @@
438439 + MEDIA_INFO(us).blockshift + MEDIA_INFO(us).pageshift);
439440 MEDIA_INFO(us).pba_to_lba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO);
440441 MEDIA_INFO(us).lba_to_pba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO);
442
+ if (MEDIA_INFO(us).pba_to_lba == NULL || MEDIA_INFO(us).lba_to_pba == NULL)
443
+ return USB_STOR_TRANSPORT_ERROR;
441444
442445 if (alauda_reset_media(us) != USB_STOR_XFER_GOOD)
443446 return USB_STOR_TRANSPORT_ERROR;
....@@ -452,9 +455,14 @@
452455 static int alauda_check_media(struct us_data *us)
453456 {
454457 struct alauda_info *info = (struct alauda_info *) us->extra;
455
- unsigned char status[2];
458
+ unsigned char *status = us->iobuf;
459
+ int rc;
456460
457
- alauda_get_media_status(us, status);
461
+ rc = alauda_get_media_status(us, status);
462
+ if (rc != USB_STOR_XFER_GOOD) {
463
+ status[0] = 0xF0; /* Pretend there's no media */
464
+ status[1] = 0;
465
+ }
458466
459467 /* Check for no media or door open */
460468 if ((status[0] & 0x80) || ((status[0] & 0x1F) == 0x10)