diff mbox series

[04/22] coda: add error handling for fget

Message ID 2514ec03df9c33b86e56748513267a80dd8004d9.1558117389.git.jaharkes@cs.cmu.edu (mailing list archive)
State New, archived
Headers show
Series Coda updates | expand

Commit Message

Jan Harkes May 17, 2019, 6:36 p.m. UTC
From: Zhouyang Jia <jiazhouyang09@gmail.com>

When fget fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling fget.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
Signed-off-by: Jan Harkes <jaharkes@cs.cmu.edu>
---
 fs/coda/psdev.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index f2bb7985d21c..12cec325384c 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -186,8 +186,11 @@  static ssize_t coda_psdev_write(struct file *file, const char __user *buf,
 	if (req->uc_opcode == CODA_OPEN_BY_FD) {
 		struct coda_open_by_fd_out *outp =
 			(struct coda_open_by_fd_out *)req->uc_data;
-		if (!outp->oh.result)
+		if (!outp->oh.result) {
 			outp->fh = fget(outp->fd);
+			if (!outp->fh)
+				return -EBADF;
+		}
 	}
 
         wake_up(&req->uc_sleep);