Commit 222a9fb3 authored by Raghava Aditya Renukunta's avatar Raghava Aditya Renukunta Committed by Martin K. Petersen

aacraid: Created new mutex for ioctl path

aac_mutex was used to create protect the ioctl path for only the compat
path, it would be make more sense to place mutex in aac_do_ioctl, which
is the main ioctl function call that handles all ioctl commands.

Created new mutex ioctl_mutex in struct aac_dev to protect switch case
in aac_do_ioctl and removed aac_mutex from aac_cfg_ioctl and
aac_compat_do_ioctl
Signed-off-by: default avatarRaghava Aditya Renukunta <RaghavaAditya.Renukunta@pmcs.com>
Reviewed-by: default avatarTomas Henzl <thenzl@redhat.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 6b93b7dd
...@@ -1124,6 +1124,7 @@ struct aac_dev ...@@ -1124,6 +1124,7 @@ struct aac_dev
struct fib *free_fib; struct fib *free_fib;
spinlock_t fib_lock; spinlock_t fib_lock;
struct mutex ioctl_mutex;
struct aac_queue_block *queues; struct aac_queue_block *queues;
/* /*
* The user API will use an IOCTL to register itself to receive * The user API will use an IOCTL to register itself to receive
......
...@@ -855,13 +855,15 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) ...@@ -855,13 +855,15 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
{ {
int status; int status;
mutex_lock(&dev->ioctl_mutex);
/* /*
* HBA gets first crack * HBA gets first crack
*/ */
status = aac_dev_ioctl(dev, cmd, arg); status = aac_dev_ioctl(dev, cmd, arg);
if (status != -ENOTTY) if (status != -ENOTTY)
return status; goto cleanup;
switch (cmd) { switch (cmd) {
case FSACTL_MINIPORT_REV_CHECK: case FSACTL_MINIPORT_REV_CHECK:
...@@ -890,6 +892,10 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) ...@@ -890,6 +892,10 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
status = -ENOTTY; status = -ENOTTY;
break; break;
} }
cleanup:
mutex_unlock(&dev->ioctl_mutex);
return status; return status;
} }
...@@ -703,23 +703,18 @@ static int aac_cfg_open(struct inode *inode, struct file *file) ...@@ -703,23 +703,18 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
static long aac_cfg_ioctl(struct file *file, static long aac_cfg_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
int ret; struct aac_dev *aac = (struct aac_dev *)file->private_data;
struct aac_dev *aac;
aac = (struct aac_dev *)file->private_data;
if (!capable(CAP_SYS_RAWIO) || aac->adapter_shutdown) if (!capable(CAP_SYS_RAWIO) || aac->adapter_shutdown)
return -EPERM; return -EPERM;
mutex_lock(&aac_mutex);
ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg);
mutex_unlock(&aac_mutex);
return ret; return aac_do_ioctl(aac, cmd, (void __user *)arg);
} }
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long arg) static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long arg)
{ {
long ret; long ret;
mutex_lock(&aac_mutex);
switch (cmd) { switch (cmd) {
case FSACTL_MINIPORT_REV_CHECK: case FSACTL_MINIPORT_REV_CHECK:
case FSACTL_SENDFIB: case FSACTL_SENDFIB:
...@@ -753,7 +748,6 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long ...@@ -753,7 +748,6 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long
ret = -ENOIOCTLCMD; ret = -ENOIOCTLCMD;
break; break;
} }
mutex_unlock(&aac_mutex);
return ret; return ret;
} }
...@@ -1194,6 +1188,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1194,6 +1188,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
goto out_free_host; goto out_free_host;
spin_lock_init(&aac->fib_lock); spin_lock_init(&aac->fib_lock);
mutex_init(&aac->ioctl_mutex);
/* /*
* Map in the registers from the adapter. * Map in the registers from the adapter.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment