Skip to content

Commit

Permalink
staging: sep: call to sep_ioctl() may leave driver in unusable state
Browse files Browse the repository at this point in the history
If sep_ioctl() is called from a process that does not own
current transaction, it unlocks unheld sep->ioctl_mutex and
returns -EACCES leaving sep->sep_mutex acquired.

The patch fixes the mutex lock-unlock mismatch.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alexey Khoroshilov authored and Greg Kroah-Hartman committed Sep 6, 2011
1 parent 1299570 commit f19885f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/staging/sep/sep_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2420,11 +2420,12 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
(sep->pid_doing_transaction != 0)) {
dev_dbg(&sep->pdev->dev, "ioctl pid is not owner\n");
error = -EACCES;
goto end_function;
}

mutex_unlock(&sep->sep_mutex);

if (error)
return error;

if (_IOC_TYPE(cmd) != SEP_IOC_MAGIC_NUMBER)
return -ENOTTY;

Expand Down Expand Up @@ -2461,7 +2462,6 @@ static long sep_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
break;
}

end_function:
mutex_unlock(&sep->ioctl_mutex);
return error;
}
Expand Down

0 comments on commit f19885f

Please sign in to comment.