From patchwork Fri Nov 23 12:07:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 10695717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 908ED1750 for ; Fri, 23 Nov 2018 12:07:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FC162B681 for ; Fri, 23 Nov 2018 12:07:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73F442B9C8; Fri, 23 Nov 2018 12:07:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 068712B681 for ; Fri, 23 Nov 2018 12:07:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394651AbeKWWvT (ORCPT ); Fri, 23 Nov 2018 17:51:19 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:42084 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390637AbeKWWvT (ORCPT ); Fri, 23 Nov 2018 17:51:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3ErahcnwZCBuElh0dlZi0Y7DwHc2psn8b3Ik56NJYj8=; b=M90wPEMLznyjY9VMpHBQfuRjF cr4ob9h154W5bfExiDUJOWt7Vls4rDtbjlYRVuNIBtWgZWYzDSXW6cdyV/xqlh/Y0G9zPf4GmOMj1 914hjr+4/C+4RNG0vi9PM1GACtvYXtDe4MCtqdTz1kOuAxjc4t4eu9yXS1d7odZVSCb2p8w2EzemL oBDh4VxjTbqdVR80VxRYKpRdsfH6K6RxfO65xbRgSxcXUnQICAFlDisRiGhBqYEd9yoezWtFRXRHb X+NAyKUuhOdXF8k3coyKh6P8Lv6NfiG7oSfVB2Ec9hMzdgjaKJJIlAakt0GjdSxYlTTsHDleZjtr4 YHTmYMeZg==; Received: from 201.47.163.210.dynamic.adsl.gvt.net.br ([201.47.163.210] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQAEy-00020N-AE; Fri, 23 Nov 2018 12:07:20 +0000 Received: from mchehab by bombadil.infradead.org with local (Exim 4.91) (envelope-from ) id 1gQAEw-0004ZQ-6e; Fri, 23 Nov 2018 07:07:18 -0500 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Linux Media Mailing List , Mauro Carvalho Chehab , Pawel Osciak , Marek Szyprowski , Kyungmin Park Subject: [PATCH] media: vb2: be sure to free on errors Date: Fri, 23 Nov 2018 07:07:17 -0500 Message-Id: X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As reported by smatch: drivers/media/common/videobuf2/videobuf2-core.c: drivers/media/common/videobuf2/videobuf2-core.c:2159 vb2_mmap() warn: inconsistent returns 'mutex:&q->mmap_lock'. Locked on: line 2148 Unlocked on: line 2100 line 2108 line 2113 line 2118 line 2156 line 2159 There is one error condition that doesn't unlock a mutex. Fixes: cd26d1c4d1bc ("media: vb2: vb2_mmap: move lock up") Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Hans Verkuil --- drivers/media/common/videobuf2/videobuf2-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 04d1250747cf..0ca81d495bda 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -2145,7 +2145,8 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) if (length < (vma->vm_end - vma->vm_start)) { dprintk(1, "MMAP invalid, as it would overflow buffer length\n"); - return -EINVAL; + ret = -EINVAL; + goto unlock; } ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma);