From: Jonathan Corbet Date: Thu, 15 May 2008 18:22:06 +0000 (-0600) Subject: sg: cdev lock_kernel() pushdown X-Git-Tag: v2.6.27-rc1~1103^2~120 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=eb09d3d4ee09b25876db549b6d5221610216e105;p=linux-2.6-omap-h63xx.git sg: cdev lock_kernel() pushdown Signed-off-by: Jonathan Corbet --- diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index c9d7f721b9e..4284625ed03 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -49,6 +49,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */ #include #include #include +#include #include "scsi.h" #include @@ -227,19 +228,26 @@ sg_open(struct inode *inode, struct file *filp) int res; int retval; + lock_kernel(); nonseekable_open(inode, filp); SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); sdp = sg_get_dev(dev); - if ((!sdp) || (!sdp->device)) + if ((!sdp) || (!sdp->device)) { + unlock_kernel(); return -ENXIO; - if (sdp->detached) + } + if (sdp->detached) { + unlock_kernel(); return -ENODEV; + } /* This driver's module count bumped by fops_get in */ /* Prevent the device driver from vanishing while we sleep */ retval = scsi_device_get(sdp->device); - if (retval) + if (retval) { + unlock_kernel(); return retval; + } if (!((flags & O_NONBLOCK) || scsi_block_when_processing_errors(sdp->device))) { @@ -295,10 +303,12 @@ sg_open(struct inode *inode, struct file *filp) retval = -ENOMEM; goto error_out; } + unlock_kernel(); return 0; error_out: scsi_device_put(sdp->device); + unlock_kernel(); return retval; }