X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=drivers%2Fscsi%2Fgdth.c;h=841101846b88fe98e55a6c601b013ef9119cdf4a;hb=f63ae56e4e97fb12053590e41a4fa59e7daa74a4;hp=b860d650a563dfd6689815bce2e908c474181610;hpb=c8710ad38900153af7a3e6762e99c062cfa46443;p=mv-sheeva.git diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index b860d650a56..841101846b8 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c @@ -120,7 +120,7 @@ #include #include #include -#include +#include #include #ifdef GDTH_RTC @@ -140,6 +140,7 @@ #include #include "gdth.h" +static DEFINE_MUTEX(gdth_mutex); static void gdth_delay(int milliseconds); static void gdth_eval_mapping(u32 size, u32 *cyls, int *heads, int *secs); static irqreturn_t gdth_interrupt(int irq, void *dev_id); @@ -372,6 +373,7 @@ static const struct file_operations gdth_fops = { .unlocked_ioctl = gdth_unlocked_ioctl, .open = gdth_open, .release = gdth_close, + .llseek = noop_llseek, }; #include "gdth_proc.h" @@ -4042,12 +4044,12 @@ static int gdth_open(struct inode *inode, struct file *filep) { gdth_ha_str *ha; - lock_kernel(); + mutex_lock(&gdth_mutex); list_for_each_entry(ha, &gdth_instances, list) { if (!ha->sdev) ha->sdev = scsi_get_host_dev(ha->shost); } - unlock_kernel(); + mutex_unlock(&gdth_mutex); TRACE(("gdth_open()\n")); return 0; @@ -4175,6 +4177,14 @@ static int ioc_general(void __user *arg, char *cmnd) ha = gdth_find_ha(gen.ionode); if (!ha) return -EFAULT; + + if (gen.data_len > INT_MAX) + return -EINVAL; + if (gen.sense_len > INT_MAX) + return -EINVAL; + if (gen.data_len + gen.sense_len > INT_MAX) + return -EINVAL; + if (gen.data_len + gen.sense_len != 0) { if (!(buf = gdth_ioctl_alloc(ha, gen.data_len + gen.sense_len, FALSE, &paddr))) @@ -4615,9 +4625,9 @@ static long gdth_unlocked_ioctl(struct file *file, unsigned int cmd, { int ret; - lock_kernel(); + mutex_lock(&gdth_mutex); ret = gdth_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&gdth_mutex); return ret; }