From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9679C433DF for ; Sat, 25 Jul 2020 06:30:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C52F1206F6 for ; Sat, 25 Jul 2020 06:30:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726944AbgGYGa4 (ORCPT ); Sat, 25 Jul 2020 02:30:56 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:52854 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726273AbgGYGa4 (ORCPT ); Sat, 25 Jul 2020 02:30:56 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 5450C3B4E21CE1DB4F4D; Sat, 25 Jul 2020 14:30:52 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Sat, 25 Jul 2020 14:30:45 +0800 From: Wei Yongjun To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Greg Kroah-Hartman CC: Wei Yongjun , , , , Hulk Robot Subject: [PATCH -next] mtd: fix missing unlock on error in mtdchar_compat_ioctl() Date: Sat, 25 Jul 2020 06:34:16 +0000 Message-ID: <20200725063416.172037-1-weiyongjun1@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Wei Yongjun --- 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;