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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 9E0D3C433B4 for ; Thu, 13 May 2021 08:29:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7635B6135A for ; Thu, 13 May 2021 08:29:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231876AbhEMIaR (ORCPT ); Thu, 13 May 2021 04:30:17 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:2060 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231305AbhEMIaP (ORCPT ); Thu, 13 May 2021 04:30:15 -0400 Received: from dggeml710-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Fgl7z5w4nzWhCS; Thu, 13 May 2021 16:24:47 +0800 (CST) Received: from dggemi762-chm.china.huawei.com (10.1.198.148) by dggeml710-chm.china.huawei.com (10.3.17.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 13 May 2021 16:29:04 +0800 Received: from linux-lmwb.huawei.com (10.175.103.112) by dggemi762-chm.china.huawei.com (10.1.198.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 13 May 2021 16:29:03 +0800 From: Zou Wei To: , , , , CC: , , Zou Wei Subject: [PATCH -next] drm/aperture: Fix missing unlock on error in devm_aperture_acquire() Date: Thu, 13 May 2021 16:46:04 +0800 Message-ID: <1620895564-52367-1-git-send-email-zou_wei@huawei.com> X-Mailer: git-send-email 2.6.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.103.112] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggemi762-chm.china.huawei.com (10.1.198.148) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the missing unlock before return from function devm_aperture_acquire() in the error handling case. Reported-by: Hulk Robot Signed-off-by: Zou Wei --- drivers/gpu/drm/drm_aperture.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_aperture.c b/drivers/gpu/drm/drm_aperture.c index 33bf018..9335d9d 100644 --- a/drivers/gpu/drm/drm_aperture.c +++ b/drivers/gpu/drm/drm_aperture.c @@ -164,13 +164,17 @@ static int devm_aperture_acquire(struct drm_device *dev, list_for_each(pos, &drm_apertures) { ap = container_of(pos, struct drm_aperture, lh); - if (overlap(base, end, ap->base, ap->base + ap->size)) + if (overlap(base, end, ap->base, ap->base + ap->size)) { + mutex_unlock(&drm_apertures_lock); return -EBUSY; + } } ap = devm_kzalloc(dev->dev, sizeof(*ap), GFP_KERNEL); - if (!ap) + if (!ap) { + mutex_unlock(&drm_apertures_lock); return -ENOMEM; + } ap->dev = dev; ap->base = base; -- 2.6.2 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 EEE9FC433ED for ; Thu, 13 May 2021 08:44:18 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9661A61404 for ; Thu, 13 May 2021 08:44:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9661A61404 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E7D1F6E069; Thu, 13 May 2021 08:44:17 +0000 (UTC) X-Greylist: delayed 910 seconds by postgrey-1.36 at gabe; Thu, 13 May 2021 08:44:17 UTC Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by gabe.freedesktop.org (Postfix) with ESMTPS id 61B176E069 for ; Thu, 13 May 2021 08:44:17 +0000 (UTC) Received: from dggeml710-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Fgl7z5w4nzWhCS; Thu, 13 May 2021 16:24:47 +0800 (CST) Received: from dggemi762-chm.china.huawei.com (10.1.198.148) by dggeml710-chm.china.huawei.com (10.3.17.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 13 May 2021 16:29:04 +0800 Received: from linux-lmwb.huawei.com (10.175.103.112) by dggemi762-chm.china.huawei.com (10.1.198.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 13 May 2021 16:29:03 +0800 From: Zou Wei To: , , , , Subject: [PATCH -next] drm/aperture: Fix missing unlock on error in devm_aperture_acquire() Date: Thu, 13 May 2021 16:46:04 +0800 Message-ID: <1620895564-52367-1-git-send-email-zou_wei@huawei.com> X-Mailer: git-send-email 2.6.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.103.112] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggemi762-chm.china.huawei.com (10.1.198.148) X-CFilter-Loop: Reflected X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zou Wei , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add the missing unlock before return from function devm_aperture_acquire() in the error handling case. Reported-by: Hulk Robot Signed-off-by: Zou Wei --- drivers/gpu/drm/drm_aperture.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_aperture.c b/drivers/gpu/drm/drm_aperture.c index 33bf018..9335d9d 100644 --- a/drivers/gpu/drm/drm_aperture.c +++ b/drivers/gpu/drm/drm_aperture.c @@ -164,13 +164,17 @@ static int devm_aperture_acquire(struct drm_device *dev, list_for_each(pos, &drm_apertures) { ap = container_of(pos, struct drm_aperture, lh); - if (overlap(base, end, ap->base, ap->base + ap->size)) + if (overlap(base, end, ap->base, ap->base + ap->size)) { + mutex_unlock(&drm_apertures_lock); return -EBUSY; + } } ap = devm_kzalloc(dev->dev, sizeof(*ap), GFP_KERNEL); - if (!ap) + if (!ap) { + mutex_unlock(&drm_apertures_lock); return -ENOMEM; + } ap->dev = dev; ap->base = base; -- 2.6.2