Message ID | 685f452cacc74f4983aaff2bc28a02a95e8aa8b7.1681414375.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1278552vqo; Thu, 13 Apr 2023 12:41:59 -0700 (PDT) X-Google-Smtp-Source: AKy350bNU6tI8Y4tXUBxTj96oTz2+h+IZtERPhvJp0FkIi8sx26rHh+8cbNOFuwaBGZ6hJK5xu8a X-Received: by 2002:a05:6a20:204a:b0:ea:ef00:3906 with SMTP id x10-20020a056a20204a00b000eaef003906mr2774896pzx.12.1681414919032; Thu, 13 Apr 2023 12:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681414919; cv=none; d=google.com; s=arc-20160816; b=dpviXbiWYnfRHtIaB522O+G56Bkw1UsB9ASg1acECq/QqzwrxYvgq+5k/h3AM5h/nq YIF313TB3T5XvWeX83C3N6fnEBzwZ4NAzD+RWcoJmWdBLuGlPN8fobliNfAgqmFgLXwx mRhhDbPfbufx5dLSgmH8MQvgUdxTVqX74cqw9IkG39vJiUkdK5zhFh8GrMbbHpeXSo8n lrXtivHqmhzb8FaK+vgUxikJHvI+Q2R7PGxT+B/9+PQ6cy73aHxaQfWqwqm/pm9eQ8ek P3HxXOwvc+wR+LMKrgOT1K4Fe5W1uwOVNSZBhJLwyZ2igKG/va7P1VmUOAy+lz3jiH/N wy4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=p8tlc8IxZvfAdUY/OUcVwiltoaAGfLctXu29jYVg/I8=; b=lL772So/nlDdQ1O0jx9AFgyevBFZwRsDdC3jfTnm8w06GLu9h21wT5R+hK/3G0au4C O628raoZQYOIwajZuBuRsFodud9W2hbxE823y99fSBfFCuEfGmUqLNETzaTVPMdnt6Vt ItT8WhZN0KgSq5LgZEA4fOUTvbPd+5RJPtjIYgN1yFY6iPbpwvpu5qgPMdL/E4RqDydq NyNWdPJsYVkzq61xDeaPc8vxZbz+7Lj3zMAZ9WsygA5Y4c2YP7UDFWAFJz277glrEcKl JBeOYzmVLjh+D6j4xbOvMPZc8nKzynWRVIroIie9ax0NkhWpnGVMTt5nReeLR2WAIZqK Egqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@orange.fr header.s=t20230301 header.b=O1nSWm5I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14-20020a63f64e000000b00503a2ab160esi2606513pgj.553.2023.04.13.12.41.44; Thu, 13 Apr 2023 12:41:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@orange.fr header.s=t20230301 header.b=O1nSWm5I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbjDMTdm (ORCPT <rfc822;peter110.wang@gmail.com> + 99 others); Thu, 13 Apr 2023 15:33:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbjDMTdl (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Apr 2023 15:33:41 -0400 Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2876F4EF8 for <linux-kernel@vger.kernel.org>; Thu, 13 Apr 2023 12:33:36 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id n2hIpROm9XvOIn2hIpu4Sp; Thu, 13 Apr 2023 21:33:34 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1681414414; bh=p8tlc8IxZvfAdUY/OUcVwiltoaAGfLctXu29jYVg/I8=; h=From:To:Cc:Subject:Date; b=O1nSWm5I/r5qvZA21kpDd+5nm9utlh0pLDctDWI6qhe9pMxWHGl3FKFAkV9XIvdZe O2rzxDasWVMEDDDqazKOsHUwLg/RL01XBSx30NTtQ+vODdZ30eikuQ7WdPzU6N8hUq RyaiwbxXSQnx6wmRHLOA8wNOyiuhUESX6al0N9RLm1Z+VHWqGQJDvpB1oJVZllR4MW NgwIjZdez5HmAyDpPgXqfrAxo8tEVU+JunpWeklzDgpVQHPOwm3P4fw3frTsJm8wOm 4CMU//G17rDAly5FRWiMlKfu5rvQTRLIfK0m7j04wMjF/8pP6s8wS9a8B7pPKJ3PpY RFvqGJzpe32fg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 13 Apr 2023 21:33:34 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Helge Deller <deller@gmx.de>, Cai Huoqing <cai.huoqing@linux.dev> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH] video: fbdev: mmp: Fix deferred clk handling in mmphw_probe() Date: Thu, 13 Apr 2023 21:33:17 +0200 Message-Id: <685f452cacc74f4983aaff2bc28a02a95e8aa8b7.1681414375.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763091330137286490?= X-GMAIL-MSGID: =?utf-8?q?1763091330137286490?= |
Series |
video: fbdev: mmp: Fix deferred clk handling in mmphw_probe()
|
|
Commit Message
Christophe JAILLET
April 13, 2023, 7:33 p.m. UTC
When dev_err_probe() is called, 'ret' holds the value of the previous
successful devm_request_irq() call.
'ret' should be assigned with a meaningful value before being used in
dev_err_probe().
While at it, use and return "PTR_ERR(ctrl->clk)" instead of a hard-coded
"-ENOENT" so that -EPROBE_DEFER is handled and propagated correctly.
Fixes: 81b63420564d ("video: fbdev: mmp: Make use of the helper function dev_err_probe()")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/video/fbdev/mmp/hw/mmp_ctrl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, Apr 13, 2023 at 09:33:17PM +0200, Christophe JAILLET wrote: > When dev_err_probe() is called, 'ret' holds the value of the previous > successful devm_request_irq() call. > 'ret' should be assigned with a meaningful value before being used in > dev_err_probe(). > > While at it, use and return "PTR_ERR(ctrl->clk)" instead of a hard-coded > "-ENOENT" so that -EPROBE_DEFER is handled and propagated correctly. > > Fixes: 81b63420564d ("video: fbdev: mmp: Make use of the helper function dev_err_probe()") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- Presumably you already wrote a Coccinelle script for this but I've added it to Smatch as well. regards, dan carpenter diff --git a/check_zero_to_err_ptr.c b/check_zero_to_err_ptr.c index 88ca0285948a..fa2a1f1603b2 100644 --- a/check_zero_to_err_ptr.c +++ b/check_zero_to_err_ptr.c @@ -157,11 +157,12 @@ static void match_err_ptr(const char *fn, struct expression *expr, void *data) { struct expression *arg_expr; struct sm_state *sm, *tmp; + int arg = PTR_INT(data); if (is_impossible_path()) return; - arg_expr = get_argument_from_call_expr(expr->args, 0); + arg_expr = get_argument_from_call_expr(expr->args, arg); sm = get_sm_state_expr(SMATCH_EXTRA, arg_expr); if (!sm) return; @@ -194,13 +195,36 @@ static void match_err_ptr(const char *fn, struct expression *expr, void *data) } END_FOR_EACH_PTR(tmp); } +static void match_err_ptr_or_zero(const char *fn, struct expression *expr, void *data) +{ + struct expression *arg; + struct range_list *rl; + char *name; + + if (is_impossible_path()) + return; + + arg = get_argument_from_call_expr(expr->args, 0); + get_absolute_rl(arg, &rl); + + if (rl_intersection(rl, valid_ptr_rl)) + return; + + name = expr_to_str(arg); + sm_warning("'%s' is never a valid pointer", name); + free_string(name); +} + void check_zero_to_err_ptr(int id) { if (option_project != PROJ_KERNEL) return; my_id = id; - add_function_hook("ERR_PTR", &match_err_ptr, NULL); - add_function_hook("ERR_CAST", &match_err_ptr, NULL); - add_function_hook("PTR_ERR", &match_err_ptr, NULL); + add_function_hook("ERR_PTR", &match_err_ptr, INT_PTR(0)); + add_function_hook("ERR_CAST", &match_err_ptr, INT_PTR(0)); + add_function_hook("PTR_ERR", &match_err_ptr, INT_PTR(0)); + add_function_hook("dev_err_probe", &match_err_ptr, INT_PTR(1)); + + add_function_hook("ERR_PTR_OR_ZERO", &match_err_ptr_or_zero, NULL); }
On Sat, Apr 15, 2023 at 04:09:03PM +0300, Dan Carpenter wrote: > On Thu, Apr 13, 2023 at 09:33:17PM +0200, Christophe JAILLET wrote: > > When dev_err_probe() is called, 'ret' holds the value of the previous > > successful devm_request_irq() call. > > 'ret' should be assigned with a meaningful value before being used in > > dev_err_probe(). > > > > While at it, use and return "PTR_ERR(ctrl->clk)" instead of a hard-coded > > "-ENOENT" so that -EPROBE_DEFER is handled and propagated correctly. > > > > Fixes: 81b63420564d ("video: fbdev: mmp: Make use of the helper function dev_err_probe()") > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > --- > > Presumably you already wrote a Coccinelle script for this but I've added > it to Smatch as well. Here is this warning: drivers/video/fbdev/mmp/hw/mmp_ctrl.c:518 mmphw_probe() warn: passing zero to 'dev_err_probe' Other warnings. All five are interesting. drivers/power/supply/rt9467-charger.c:1026 rt9467_request_interrupt() warn: passing zero to 'dev_err_probe' drivers/pci/controller/dwc/pcie-bt1.c:601 bt1_pcie_add_port() warn: passing zero to 'dev_err_probe' drivers/spi/spi-sprd-adi.c:570 sprd_adi_probe() warn: passing zero to 'dev_err_probe' drivers/soc/qcom/icc-bwmon.c:776 bwmon_probe() warn: passing zero to 'dev_err_probe' drivers/soc/qcom/icc-bwmon.c:781 bwmon_probe() warn: passing zero to 'dev_err_probe' regards, dan carpenter
Le 19/04/2023 à 06:59, Dan Carpenter a écrit : > On Sat, Apr 15, 2023 at 04:09:03PM +0300, Dan Carpenter wrote: >> On Thu, Apr 13, 2023 at 09:33:17PM +0200, Christophe JAILLET wrote: >>> When dev_err_probe() is called, 'ret' holds the value of the previous >>> successful devm_request_irq() call. >>> 'ret' should be assigned with a meaningful value before being used in >>> dev_err_probe(). >>> >>> While at it, use and return "PTR_ERR(ctrl->clk)" instead of a hard-coded >>> "-ENOENT" so that -EPROBE_DEFER is handled and propagated correctly. >>> >>> Fixes: 81b63420564d ("video: fbdev: mmp: Make use of the helper function dev_err_probe()") >>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> >>> --- >> >> Presumably you already wrote a Coccinelle script for this but I've added >> it to Smatch as well. No I haven't. I've spotted it while looking at some devm_clk_get_optional() candidate with grep. git grep -A5 devm_clk_get | grep -B5 ENOENT Not perfect, but sometimes this kind of approach can find interesting things coccinelle would miss. As an example, the bitmap_alloc patch on sh4 was found this way, with grep. So nice to have it in smatch, ;-) CJ > > Here is this warning: > drivers/video/fbdev/mmp/hw/mmp_ctrl.c:518 mmphw_probe() warn: passing zero to 'dev_err_probe' > > Other warnings. All five are interesting. > drivers/power/supply/rt9467-charger.c:1026 rt9467_request_interrupt() warn: passing zero to 'dev_err_probe' > drivers/pci/controller/dwc/pcie-bt1.c:601 bt1_pcie_add_port() warn: passing zero to 'dev_err_probe' > drivers/spi/spi-sprd-adi.c:570 sprd_adi_probe() warn: passing zero to 'dev_err_probe' > drivers/soc/qcom/icc-bwmon.c:776 bwmon_probe() warn: passing zero to 'dev_err_probe' > drivers/soc/qcom/icc-bwmon.c:781 bwmon_probe() warn: passing zero to 'dev_err_probe' > > regards, > dan carpenter > >
On 4/13/23 21:33, Christophe JAILLET wrote: > When dev_err_probe() is called, 'ret' holds the value of the previous > successful devm_request_irq() call. > 'ret' should be assigned with a meaningful value before being used in > dev_err_probe(). > > While at it, use and return "PTR_ERR(ctrl->clk)" instead of a hard-coded > "-ENOENT" so that -EPROBE_DEFER is handled and propagated correctly. > > Fixes: 81b63420564d ("video: fbdev: mmp: Make use of the helper function dev_err_probe()") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > drivers/video/fbdev/mmp/hw/mmp_ctrl.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) applied. Thanks! Helge > > diff --git a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c > index a9df8ee79810..51fbf02a0343 100644 > --- a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c > +++ b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c > @@ -514,9 +514,9 @@ static int mmphw_probe(struct platform_device *pdev) > /* get clock */ > ctrl->clk = devm_clk_get(ctrl->dev, mi->clk_name); > if (IS_ERR(ctrl->clk)) { > + ret = PTR_ERR(ctrl->clk); > dev_err_probe(ctrl->dev, ret, > "unable to get clk %s\n", mi->clk_name); > - ret = -ENOENT; > goto failed; > } > clk_prepare_enable(ctrl->clk);
diff --git a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c index a9df8ee79810..51fbf02a0343 100644 --- a/drivers/video/fbdev/mmp/hw/mmp_ctrl.c +++ b/drivers/video/fbdev/mmp/hw/mmp_ctrl.c @@ -514,9 +514,9 @@ static int mmphw_probe(struct platform_device *pdev) /* get clock */ ctrl->clk = devm_clk_get(ctrl->dev, mi->clk_name); if (IS_ERR(ctrl->clk)) { + ret = PTR_ERR(ctrl->clk); dev_err_probe(ctrl->dev, ret, "unable to get clk %s\n", mi->clk_name); - ret = -ENOENT; goto failed; } clk_prepare_enable(ctrl->clk);