linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] mtd: fix missing unlock on error in mtdchar_compat_ioctl()
@ 2020-07-25  6:34 Wei Yongjun
  2020-07-25  6:37 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Wei Yongjun @ 2020-07-25  6:34 UTC (permalink / raw)
  To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	Greg Kroah-Hartman
  Cc: linux-mtd, kernel-janitors, Wei Yongjun, linux-kernel, Hulk Robot

Add the missing unlock before return from function mtdchar_compat_ioctl()
in the error handling case.

Fixes: 210bec567936 ("mtd: properly check all write ioctls for permissions")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/mtd/mtdchar.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 52c120f9fb0d..b40f46a43fc6 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1064,8 +1064,10 @@ static long mtdchar_compat_ioctl(struct file *file, unsigned int cmd,
 		struct mtd_oob_buf32 buf;
 		struct mtd_oob_buf32 __user *buf_user = argp;
 
-		if (!(file->f_mode & FMODE_WRITE))
-			return -EPERM;
+		if (!(file->f_mode & FMODE_WRITE)) {
+			ret = -EPERM;
+			break;
+		}
 
 		if (copy_from_user(&buf, argp, sizeof(buf)))
 			ret = -EFAULT;




______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-25  8:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-25  6:34 [PATCH -next] mtd: fix missing unlock on error in mtdchar_compat_ioctl() Wei Yongjun
2020-07-25  6:37 ` Greg Kroah-Hartman
2020-07-25  8:13   ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).