aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ses.c
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2008-07-29 12:38:25 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-07-30 11:21:56 -0400
commit671a99c8eb2f1dde08ac5538d8cd912047c61ddf (patch)
treeb02cba45dbe7a69a7c9c24aa815bd3e82fde7725 /drivers/scsi/ses.c
parentad337591f4fd20de6a0ca03d6715267a5c1d2b16 (diff)
[SCSI] ses: fix VPD inquiry overrun
There are a few kerneloops.org reports like this one: http://www.kerneloops.org/search.php?search=ses_match_to_enclosure That seem to imply we're running off the end of the VPD inquiry data (although at 512 bytes, it should be long enough for just about anything). we should be using correctly sized buffers anyway, so put those in and hope this oops goes away. Cc: Stable Tree <stable@kernel.org> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/ses.c')
-rw-r--r--drivers/scsi/ses.c18
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
350static void ses_match_to_enclosure(struct enclosure_device *edev, 350static 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;