Commit 736d5453 authored by Dan Carpenter's avatar Dan Carpenter Committed by Linus Torvalds

sx.c: fix missed unlock_kernel() on error path in sx_fw_ioctl()

If we return directly with -EPERM then lock_kernel() is still held.

This was found with a code checker (http://repo.or.cz/w/smatch.git/).

[akpm@linux-foundation.org: fix another such path - missed func_exit()]
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Cc: <R.E.Wolff@BitWizard.nl>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fe86175b
...@@ -1713,8 +1713,8 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd, ...@@ -1713,8 +1713,8 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd,
for (i = 0; i < SX_NBOARDS; i++) for (i = 0; i < SX_NBOARDS; i++)
sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags); sx_dprintk(SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags);
sx_dprintk(SX_DEBUG_FIRMWARE, "\n"); sx_dprintk(SX_DEBUG_FIRMWARE, "\n");
unlock_kernel(); rc = -EIO;
return -EIO; goto out;
} }
switch (cmd) { switch (cmd) {
...@@ -1747,7 +1747,8 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd, ...@@ -1747,7 +1747,8 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd,
break; break;
case SXIO_DO_RAMTEST: case SXIO_DO_RAMTEST:
if (sx_initialized) /* Already initialized: better not ramtest the board. */ if (sx_initialized) /* Already initialized: better not ramtest the board. */
return -EPERM; rc = -EPERM;
break;
if (IS_SX_BOARD(board)) { if (IS_SX_BOARD(board)) {
rc = do_memtest(board, 0, 0x7000); rc = do_memtest(board, 0, 0x7000);
if (!rc) if (!rc)
...@@ -1844,6 +1845,7 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd, ...@@ -1844,6 +1845,7 @@ static long sx_fw_ioctl(struct file *filp, unsigned int cmd,
rc = -ENOTTY; rc = -ENOTTY;
break; break;
} }
out:
unlock_kernel(); unlock_kernel();
func_exit(); func_exit();
return rc; return rc;
......
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