Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: osd_uld: Check scsi_device_get() return value

scsi_device_get() can fail. Hence check its return value.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Boaz Harrosh <bharrosh@panasas.com>
Acked-by: Boaz Harrosh <ooo@electrozaur.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
c02465fa 8690218a

+5 -3
+5 -3
drivers/scsi/osd/osd_uld.c
··· 464 464 /* hold one more reference to the scsi_device that will get released 465 465 * in __release, in case a logout is happening while fs is mounted 466 466 */ 467 - scsi_device_get(scsi_device); 467 + if (scsi_device_get(scsi_device)) 468 + goto err_put_disk; 468 469 osd_dev_init(&oud->od, scsi_device); 469 470 470 471 /* Detect the OSD Version */ 471 472 error = __detect_osd(oud); 472 473 if (error) { 473 474 OSD_ERR("osd detection failed, non-compatible OSD device\n"); 474 - goto err_put_disk; 475 + goto err_put_sdev; 475 476 } 476 477 477 478 /* init the char-device for communication with user-mode */ ··· 509 508 510 509 err_put_cdev: 511 510 cdev_del(&oud->cdev); 512 - err_put_disk: 511 + err_put_sdev: 513 512 scsi_device_put(scsi_device); 513 + err_put_disk: 514 514 put_disk(disk); 515 515 err_free_osd: 516 516 dev_set_drvdata(dev, NULL);