Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1506645 > unrolled thread

[PATCH] clk: keystone: Fix an error checking

Started byChristophe JAILLET <christophe.jaillet@wanadoo.fr>
First post2016-10-23 10:20 +0200
Last post2016-10-24 22:20 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] clk: keystone: Fix an error checking Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-10-23 10:20 +0200
    Re: [PATCH] clk: keystone: Fix an error checking Dan Carpenter <dan.carpenter@oracle.com> - 2016-10-24 12:40 +0200
      Re: [PATCH] clk: keystone: Fix an error checking Lars-Peter Clausen <lars@metafoo.de> - 2016-10-24 12:50 +0200
        Re: [PATCH] clk: keystone: Fix an error checking Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-10-24 22:20 +0200

#1506645 — [PATCH] clk: keystone: Fix an error checking

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2016-10-23 10:20 +0200
Subject[PATCH] clk: keystone: Fix an error checking
Message-ID<svmaB-6Vi-5@gated-at.bofh.it>
clk_register_pll() can return ERR_PTR(-ENOMEM) so here the check against
NULL only is not correct.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Un-compiled and un-tested.
---
 drivers/clk/keystone/pll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/keystone/pll.c b/drivers/clk/keystone/pll.c
index a26ba2184454..b936029fa211 100644
--- a/drivers/clk/keystone/pll.c
+++ b/drivers/clk/keystone/pll.c
@@ -213,7 +213,7 @@ static void __init _of_pll_clk_init(struct device_node *node, bool pllctrl)
 	}
 
 	clk = clk_register_pll(NULL, node->name, parent_name, pll_data);
-	if (clk) {
+	if (!IS_ERR_OR_NULL(clk)) {
 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
 		return;
 	}
-- 
2.9.3

[toc] | [next] | [standalone]


#1507083

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-10-24 12:40 +0200
Message-ID<svKPD-6q5-7@gated-at.bofh.it>
In reply to#1506645
On Sun, Oct 23, 2016 at 10:12:49AM +0200, Christophe JAILLET wrote:
> clk_register_pll() can return ERR_PTR(-ENOMEM) so here the check against
> NULL only is not correct.
> 

Change the ERR_PTR(-ENOMEM) to a NULL instead.  When we mix error
pointers and NULL, what it means is that NULL should be treated as a
success case.  That's not the case here, so we should just return NULL
since we don't actually care about the error codes.

regards,
dan carpenter

[toc] | [prev] | [next] | [standalone]


#1507086

FromLars-Peter Clausen <lars@metafoo.de>
Date2016-10-24 12:50 +0200
Message-ID<svKZj-6tF-5@gated-at.bofh.it>
In reply to#1507083
On 10/24/2016 12:36 PM, Dan Carpenter wrote:
> On Sun, Oct 23, 2016 at 10:12:49AM +0200, Christophe JAILLET wrote:
>> clk_register_pll() can return ERR_PTR(-ENOMEM) so here the check against
>> NULL only is not correct.
>>
> 
> Change the ERR_PTR(-ENOMEM) to a NULL instead.

In this particular case propagate the error returned by clk_register().

[toc] | [prev] | [next] | [standalone]


#1507691

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2016-10-24 22:20 +0200
Message-ID<svTSW-43c-9@gated-at.bofh.it>
In reply to#1507086
Hi,

Thanks for the review and comments.

I'll send another patch for that.
It will not be tagged as v2 because it will be part of a patch set for 
some other potential fixes.

CJ

Le 24/10/2016 à 12:41, Lars-Peter Clausen a écrit :
> On 10/24/2016 12:36 PM, Dan Carpenter wrote:
>> On Sun, Oct 23, 2016 at 10:12:49AM +0200, Christophe JAILLET wrote:
>>> clk_register_pll() can return ERR_PTR(-ENOMEM) so here the check against
>>> NULL only is not correct.
>>>
>> Change the ERR_PTR(-ENOMEM) to a NULL instead.
> In this particular case propagate the error returned by clk_register().
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-clk" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web