hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/scsi/scsi.c
....@@ -317,11 +317,18 @@
317317 if (result)
318318 return -EIO;
319319
320
- /* Sanity check that we got the page back that we asked for */
320
+ /*
321
+ * Sanity check that we got the page back that we asked for and that
322
+ * the page size is not 0.
323
+ */
321324 if (buffer[1] != page)
322325 return -EIO;
323326
324
- return get_unaligned_be16(&buffer[2]) + 4;
327
+ result = get_unaligned_be16(&buffer[2]);
328
+ if (!result)
329
+ return -EIO;
330
+
331
+ return result + 4;
325332 }
326333
327334 /**