diff options
Diffstat (limited to 'drivers/scsi/ses.c')
-rw-r--r-- | drivers/scsi/ses.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 0fe031f003e7..1bcf3c33d7ff 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c | |||
@@ -345,14 +345,14 @@ static int ses_enclosure_find_by_addr(struct enclosure_device *edev, | |||
345 | return 0; | 345 | return 0; |
346 | } | 346 | } |
347 | 347 | ||
348 | #define VPD_INQUIRY_SIZE 512 | 348 | #define VPD_INQUIRY_SIZE 36 |
349 | 349 | ||
350 | static void ses_match_to_enclosure(struct enclosure_device *edev, | 350 | static void ses_match_to_enclosure(struct enclosure_device *edev, |
351 | struct scsi_device *sdev) | 351 | struct scsi_device *sdev) |
352 | { | 352 | { |
353 | unsigned char *buf = kmalloc(VPD_INQUIRY_SIZE, GFP_KERNEL); | 353 | unsigned char *buf = kmalloc(VPD_INQUIRY_SIZE, GFP_KERNEL); |
354 | unsigned char *desc; | 354 | unsigned char *desc; |
355 | int len; | 355 | u16 vpd_len; |
356 | struct efd efd = { | 356 | struct efd efd = { |
357 | .addr = 0, | 357 | .addr = 0, |
358 | }; | 358 | }; |
@@ -372,9 +372,19 @@ static void ses_match_to_enclosure(struct enclosure_device *edev, | |||
372 | VPD_INQUIRY_SIZE, NULL, SES_TIMEOUT, SES_RETRIES)) | 372 | VPD_INQUIRY_SIZE, NULL, SES_TIMEOUT, SES_RETRIES)) |
373 | goto free; | 373 | goto free; |
374 | 374 | ||
375 | len = (buf[2] << 8) + buf[3]; | 375 | vpd_len = (buf[2] << 8) + buf[3]; |
376 | kfree(buf); | ||
377 | buf = kmalloc(vpd_len, GFP_KERNEL); | ||
378 | if (!buf) | ||
379 | return; | ||
380 | cmd[3] = vpd_len >> 8; | ||
381 | cmd[4] = vpd_len & 0xff; | ||
382 | if (scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buf, | ||
383 | vpd_len, NULL, SES_TIMEOUT, SES_RETRIES)) | ||
384 | goto free; | ||
385 | |||
376 | desc = buf + 4; | 386 | desc = buf + 4; |
377 | while (desc < buf + len) { | 387 | while (desc < buf + vpd_len) { |
378 | enum scsi_protocol proto = desc[0] >> 4; | 388 | enum scsi_protocol proto = desc[0] >> 4; |
379 | u8 code_set = desc[0] & 0x0f; | 389 | u8 code_set = desc[0] & 0x0f; |
380 | u8 piv = desc[1] & 0x80; | 390 | u8 piv = desc[1] & 0x80; |