aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sg.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/sg.c')
-rw-r--r--drivers/scsi/sg.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index d4af13269e85..64df1ab141e5 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -295,23 +295,20 @@ sg_open(struct inode *inode, struct file *filp)
295 if (flags & O_EXCL) 295 if (flags & O_EXCL)
296 sdp->exclude = 1; /* used by release lock */ 296 sdp->exclude = 1; /* used by release lock */
297 297
298 if (sdp->detached) {
299 retval = -ENODEV;
300 goto sem_out;
301 }
302 if (sfds_list_empty(sdp)) { /* no existing opens on this device */ 298 if (sfds_list_empty(sdp)) { /* no existing opens on this device */
303 sdp->sgdebug = 0; 299 sdp->sgdebug = 0;
304 q = sdp->device->request_queue; 300 q = sdp->device->request_queue;
305 sdp->sg_tablesize = queue_max_segments(q); 301 sdp->sg_tablesize = queue_max_segments(q);
306 } 302 }
307 if ((sfp = sg_add_sfp(sdp, dev))) 303 sfp = sg_add_sfp(sdp, dev);
304 if (!IS_ERR(sfp))
308 filp->private_data = sfp; 305 filp->private_data = sfp;
309 /* retval is already provably zero at this point because of the 306 /* retval is already provably zero at this point because of the
310 * check after retval = scsi_autopm_get_device(sdp->device)) 307 * check after retval = scsi_autopm_get_device(sdp->device))
311 */ 308 */
312 else { 309 else {
313 retval = -ENOMEM; 310 retval = PTR_ERR(sfp);
314sem_out: 311
315 if (flags & O_EXCL) { 312 if (flags & O_EXCL) {
316 sdp->exclude = 0; /* undo if error */ 313 sdp->exclude = 0; /* undo if error */
317 up_write(&sdp->o_sem); 314 up_write(&sdp->o_sem);
@@ -2045,7 +2042,7 @@ sg_add_sfp(Sg_device * sdp, int dev)
2045 2042
2046 sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN); 2043 sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN);
2047 if (!sfp) 2044 if (!sfp)
2048 return NULL; 2045 return ERR_PTR(-ENOMEM);
2049 2046
2050 init_waitqueue_head(&sfp->read_wait); 2047 init_waitqueue_head(&sfp->read_wait);
2051 rwlock_init(&sfp->rq_list_lock); 2048 rwlock_init(&sfp->rq_list_lock);
@@ -2060,6 +2057,10 @@ sg_add_sfp(Sg_device * sdp, int dev)
2060 sfp->keep_orphan = SG_DEF_KEEP_ORPHAN; 2057 sfp->keep_orphan = SG_DEF_KEEP_ORPHAN;
2061 sfp->parentdp = sdp; 2058 sfp->parentdp = sdp;
2062 write_lock_irqsave(&sg_index_lock, iflags); 2059 write_lock_irqsave(&sg_index_lock, iflags);
2060 if (sdp->detached) {
2061 write_unlock_irqrestore(&sg_index_lock, iflags);
2062 return ERR_PTR(-ENODEV);
2063 }
2063 list_add_tail(&sfp->sfd_siblings, &sdp->sfds); 2064 list_add_tail(&sfp->sfd_siblings, &sdp->sfds);
2064 write_unlock_irqrestore(&sg_index_lock, iflags); 2065 write_unlock_irqrestore(&sg_index_lock, iflags);
2065 SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: sfp=0x%p\n", sfp)); 2066 SCSI_LOG_TIMEOUT(3, printk("sg_add_sfp: sfp=0x%p\n", sfp));