Linux Framebuffer Layer development
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Helge Deller <deller@gmx.de>, Cai Huoqing <cai.huoqing@linux.dev>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] video: fbdev: mmp: Fix deferred clk handling in mmphw_probe()
Date: Sat, 15 Apr 2023 16:09:03 +0300	[thread overview]
Message-ID: <67353089-4966-424c-99c2-8524818f0e37@kili.mountain> (raw)
In-Reply-To: <685f452cacc74f4983aaff2bc28a02a95e8aa8b7.1681414375.git.christophe.jaillet@wanadoo.fr>

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);
 }

  reply	other threads:[~2023-04-15 13:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13 19:33 [PATCH] video: fbdev: mmp: Fix deferred clk handling in mmphw_probe() Christophe JAILLET
2023-04-15 13:09 ` Dan Carpenter [this message]
2023-04-19  4:59   ` Dan Carpenter
2023-04-19  5:28     ` Christophe JAILLET
2023-04-22  9:41 ` Helge Deller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=67353089-4966-424c-99c2-8524818f0e37@kili.mountain \
    --to=error27@gmail.com \
    --cc=cai.huoqing@linux.dev \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox