Commit eca41044 authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds

n_r3964: fix lock imbalance

There is omitted BKunL in r3964_read.

Centralize the paths to one point with one unlock.
Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Cc: stable@kernel.org
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 52e3632e
...@@ -1062,7 +1062,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file, ...@@ -1062,7 +1062,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
struct r3964_client_info *pClient; struct r3964_client_info *pClient;
struct r3964_message *pMsg; struct r3964_message *pMsg;
struct r3964_client_message theMsg; struct r3964_client_message theMsg;
int count; int ret;
TRACE_L("read()"); TRACE_L("read()");
...@@ -1074,8 +1074,8 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file, ...@@ -1074,8 +1074,8 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
if (pMsg == NULL) { if (pMsg == NULL) {
/* no messages available. */ /* no messages available. */
if (file->f_flags & O_NONBLOCK) { if (file->f_flags & O_NONBLOCK) {
unlock_kernel(); ret = -EAGAIN;
return -EAGAIN; goto unlock;
} }
/* block until there is a message: */ /* block until there is a message: */
wait_event_interruptible(pInfo->read_wait, wait_event_interruptible(pInfo->read_wait,
...@@ -1085,29 +1085,31 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file, ...@@ -1085,29 +1085,31 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
/* If we still haven't got a message, we must have been signalled */ /* If we still haven't got a message, we must have been signalled */
if (!pMsg) { if (!pMsg) {
unlock_kernel(); ret = -EINTR;
return -EINTR; goto unlock;
} }
/* deliver msg to client process: */ /* deliver msg to client process: */
theMsg.msg_id = pMsg->msg_id; theMsg.msg_id = pMsg->msg_id;
theMsg.arg = pMsg->arg; theMsg.arg = pMsg->arg;
theMsg.error_code = pMsg->error_code; theMsg.error_code = pMsg->error_code;
count = sizeof(struct r3964_client_message); ret = sizeof(struct r3964_client_message);
kfree(pMsg); kfree(pMsg);
TRACE_M("r3964_read - msg kfree %p", pMsg); TRACE_M("r3964_read - msg kfree %p", pMsg);
if (copy_to_user(buf, &theMsg, count)) { if (copy_to_user(buf, &theMsg, ret)) {
unlock_kernel(); ret = -EFAULT;
return -EFAULT; goto unlock;
} }
TRACE_PS("read - return %d", count); TRACE_PS("read - return %d", ret);
return count; goto unlock;
} }
ret = -EPERM;
unlock:
unlock_kernel(); unlock_kernel();
return -EPERM; return ret;
} }
static ssize_t r3964_write(struct tty_struct *tty, struct file *file, static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
......
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