All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sh: clk: Extend valid clk ptr checks using IS_ERR_OR_NULL
@ 2022-05-23  9:16 Phil Edworthy
  2022-05-27 17:40 ` Rob Landley
  2022-07-08  7:54 ` Geert Uytterhoeven
  0 siblings, 2 replies; 4+ messages in thread
From: Phil Edworthy @ 2022-05-23  9:16 UTC (permalink / raw)
  To: Yoshinori Sato, Rich Felker; +Cc: Phil Edworthy, linux-sh, Geert Uytterhoeven

In order to allow all drivers to call clk functions with an invalid clk
ptr, ensure we check not only for a NULL clk ptr, but also for errors
before using it.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
---
Note this has not been tested at all, I don't have any SH boards.
---
 drivers/sh/clk/core.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c
index d996782a7106..b843c99b3604 100644
--- a/drivers/sh/clk/core.c
+++ b/drivers/sh/clk/core.c
@@ -253,7 +253,7 @@ void clk_disable(struct clk *clk)
 {
 	unsigned long flags;
 
-	if (!clk)
+	if (IS_ERR_OR_NULL(clk))
 		return;
 
 	spin_lock_irqsave(&clock_lock, flags);
@@ -294,7 +294,7 @@ int clk_enable(struct clk *clk)
 	unsigned long flags;
 	int ret;
 
-	if (!clk)
+	if (IS_ERR_OR_NULL(clk))
 		return -EINVAL;
 
 	spin_lock_irqsave(&clock_lock, flags);
@@ -470,7 +470,7 @@ void clk_enable_init_clocks(void)
 
 unsigned long clk_get_rate(struct clk *clk)
 {
-	if (!clk)
+	if (IS_ERR_OR_NULL(clk))
 		return 0;
 
 	return clk->rate;
@@ -482,7 +482,7 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
 	int ret = -EOPNOTSUPP;
 	unsigned long flags;
 
-	if (!clk)
+	if (IS_ERR_OR_NULL(clk))
 		return 0;
 
 	spin_lock_irqsave(&clock_lock, flags);
@@ -513,7 +513,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 	unsigned long flags;
 	int ret = -EINVAL;
 
-	if (!parent || !clk)
+	if (!parent || IS_ERR_OR_NULL(clk))
 		return ret;
 	if (clk->parent == parent)
 		return 0;
@@ -542,7 +542,7 @@ EXPORT_SYMBOL_GPL(clk_set_parent);
 
 struct clk *clk_get_parent(struct clk *clk)
 {
-	if (!clk)
+	if (IS_ERR_OR_NULL(clk))
 		return NULL;
 
 	return clk->parent;
@@ -551,7 +551,7 @@ EXPORT_SYMBOL_GPL(clk_get_parent);
 
 long clk_round_rate(struct clk *clk, unsigned long rate)
 {
-	if (!clk)
+	if (IS_ERR_OR_NULL(clk))
 		return 0;
 
 	if (likely(clk->ops && clk->ops->round_rate)) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-08 10:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-23  9:16 [PATCH] sh: clk: Extend valid clk ptr checks using IS_ERR_OR_NULL Phil Edworthy
2022-05-27 17:40 ` Rob Landley
2022-07-08  7:54 ` Geert Uytterhoeven
2022-07-08 10:23   ` Phil Edworthy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.