Skip to content

Commit 222a9fb

Browse files
Raghava Aditya Renukuntamartinkpetersen
authored andcommitted
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: Raghava Aditya Renukunta <[email protected]> Reviewed-by: Tomas Henzl <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 6b93b7d commit 222a9fb

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

drivers/scsi/aacraid/aacraid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,7 @@ struct aac_dev
11241124
struct fib *free_fib;
11251125
spinlock_t fib_lock;
11261126

1127+
struct mutex ioctl_mutex;
11271128
struct aac_queue_block *queues;
11281129
/*
11291130
* The user API will use an IOCTL to register itself to receive

drivers/scsi/aacraid/commctrl.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,13 +855,15 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
855855
{
856856
int status;
857857

858+
mutex_lock(&dev->ioctl_mutex);
859+
858860
/*
859861
* HBA gets first crack
860862
*/
861863

862864
status = aac_dev_ioctl(dev, cmd, arg);
863865
if (status != -ENOTTY)
864-
return status;
866+
goto cleanup;
865867

866868
switch (cmd) {
867869
case FSACTL_MINIPORT_REV_CHECK:
@@ -890,6 +892,10 @@ int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg)
890892
status = -ENOTTY;
891893
break;
892894
}
895+
896+
cleanup:
897+
mutex_unlock(&dev->ioctl_mutex);
898+
893899
return status;
894900
}
895901

drivers/scsi/aacraid/linit.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -703,23 +703,18 @@ static int aac_cfg_open(struct inode *inode, struct file *file)
703703
static long aac_cfg_ioctl(struct file *file,
704704
unsigned int cmd, unsigned long arg)
705705
{
706-
int ret;
707-
struct aac_dev *aac;
708-
aac = (struct aac_dev *)file->private_data;
706+
struct aac_dev *aac = (struct aac_dev *)file->private_data;
707+
709708
if (!capable(CAP_SYS_RAWIO) || aac->adapter_shutdown)
710709
return -EPERM;
711-
mutex_lock(&aac_mutex);
712-
ret = aac_do_ioctl(file->private_data, cmd, (void __user *)arg);
713-
mutex_unlock(&aac_mutex);
714710

715-
return ret;
711+
return aac_do_ioctl(aac, cmd, (void __user *)arg);
716712
}
717713

718714
#ifdef CONFIG_COMPAT
719715
static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long arg)
720716
{
721717
long ret;
722-
mutex_lock(&aac_mutex);
723718
switch (cmd) {
724719
case FSACTL_MINIPORT_REV_CHECK:
725720
case FSACTL_SENDFIB:
@@ -753,7 +748,6 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long
753748
ret = -ENOIOCTLCMD;
754749
break;
755750
}
756-
mutex_unlock(&aac_mutex);
757751
return ret;
758752
}
759753

@@ -1194,6 +1188,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
11941188
goto out_free_host;
11951189
spin_lock_init(&aac->fib_lock);
11961190

1191+
mutex_init(&aac->ioctl_mutex);
11971192
/*
11981193
* Map in the registers from the adapter.
11991194
*/

0 commit comments

Comments
 (0)