From: Zhouyang Jia <jiazhouyang09@xxxxxxxxx> 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@xxxxxxxxx> Signed-off-by: Jan Harkes <jaharkes@xxxxxxxxxx> --- fs/coda/psdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index c5234c21b539..55824cba3245 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -187,8 +187,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); -- 2.20.1