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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ACE3C47088 for ; Thu, 1 Dec 2022 02:09:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbiLACJ2 (ORCPT ); Wed, 30 Nov 2022 21:09:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbiLACJ0 (ORCPT ); Wed, 30 Nov 2022 21:09:26 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE3743857; Wed, 30 Nov 2022 18:09:25 -0800 (PST) Received: from kwepemi500014.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NMzyL0gfFzmWBp; Thu, 1 Dec 2022 10:08:42 +0800 (CST) Received: from [10.174.176.189] (10.174.176.189) by kwepemi500014.china.huawei.com (7.221.188.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 1 Dec 2022 10:09:23 +0800 Message-ID: <683df422-68f2-12e3-ff5e-66c45e567db2@huawei.com> Date: Thu, 1 Dec 2022 10:09:22 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH] media: platform: mtk-mdp3: Fix return value check in mdp_probe() To: AngeloGioacchino Del Regno CC: , , , , , References: <20221130081312.35523-1-linqiheng@huawei.com> From: Qiheng Lin In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.176.189] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemi500014.china.huawei.com (7.221.188.232) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/11/30 17:44, AngeloGioacchino Del Regno 写道: > Il 30/11/22 09:13, Qiheng Lin ha scritto: >> In case of error, the function mtk_mutex_get() >> returns ERR_PTR() and never returns NULL. The NULL test in the >> return value check should be replaced with IS_ERR(). >> >> Fixes: 61890ccaefaf ("media: platform: mtk-mdp3: add MediaTek MDP3 >> driver") >> Signed-off-by: Qiheng Lin >> --- >>   drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 4 ++-- >>   1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c >> b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c >> index c413e59d4286..7a2d992dd842 100644 >> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c >> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c >> @@ -207,8 +207,8 @@ static int mdp_probe(struct platform_device *pdev) >>       } >>       for (i = 0; i < MDP_PIPE_MAX; i++) { >>           mdp->mdp_mutex[i] = mtk_mutex_get(&mm_pdev->dev); >> -        if (!mdp->mdp_mutex[i]) { >> -            ret = -ENODEV; >> +        if (IS_ERR(mdp->mdp_mutex[i])) { >> +            ret = PTR_ERR(mdp->mdp_mutex[i]); >>               goto err_return; >>           } >>       } >> > > That's true, and I fully agree. > While you're at it, can you also fix the err_return case? > > if (mdp) >     for ... >         if (!IS_ERR_OR_NULL(mdp->mdp_mutex[i])) >             mtk_mutex_put(...) > Thanks for your suggestion, will send the v2. > Thanks, > Angelo