All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1] clk: clk-uclass: Check ops pointer before use it
@ 2016-08-17  7:05 Wenyou Yang
  2016-08-17 15:59 ` Stephen Warren
  0 siblings, 1 reply; 11+ messages in thread
From: Wenyou Yang @ 2016-08-17  7:05 UTC (permalink / raw)
  To: u-boot

Add check ops pointer before use it. Otherwise, it will cause
the runtime error for the clk devices without ops callback.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
---

 drivers/clk/clk-uclass.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 4d78e3f..13b8739 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -82,7 +82,7 @@ int clk_get_by_index(struct udevice *dev, int index, struct clk *clk)
 	}
 	ops = clk_dev_ops(dev_clk);
 
-	if (ops->of_xlate)
+	if (ops && ops->of_xlate)
 		ret = ops->of_xlate(clk, &args);
 	else
 		ret = clk_of_xlate_default(clk, &args);
@@ -120,7 +120,7 @@ int clk_request(struct udevice *dev, struct clk *clk)
 
 	clk->dev = dev;
 
-	if (!ops->request)
+	if (!ops || !ops->request)
 		return 0;
 
 	return ops->request(clk);
@@ -132,7 +132,7 @@ int clk_free(struct clk *clk)
 
 	debug("%s(clk=%p)\n", __func__, clk);
 
-	if (!ops->free)
+	if (!ops || !ops->free)
 		return 0;
 
 	return ops->free(clk);
@@ -144,7 +144,7 @@ ulong clk_get_rate(struct clk *clk)
 
 	debug("%s(clk=%p)\n", __func__, clk);
 
-	if (!ops->get_rate)
+	if (!ops || !ops->get_rate)
 		return -ENOSYS;
 
 	return ops->get_rate(clk);
@@ -156,7 +156,7 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
 
 	debug("%s(clk=%p, rate=%lu)\n", __func__, clk, rate);
 
-	if (!ops->set_rate)
+	if (!ops || !ops->set_rate)
 		return -ENOSYS;
 
 	return ops->set_rate(clk, rate);
@@ -168,7 +168,7 @@ int clk_enable(struct clk *clk)
 
 	debug("%s(clk=%p)\n", __func__, clk);
 
-	if (!ops->enable)
+	if (!ops || !ops->enable)
 		return -ENOSYS;
 
 	return ops->enable(clk);
@@ -180,7 +180,7 @@ int clk_disable(struct clk *clk)
 
 	debug("%s(clk=%p)\n", __func__, clk);
 
-	if (!ops->disable)
+	if (!ops || !ops->disable)
 		return -ENOSYS;
 
 	return ops->disable(clk);
-- 
2.7.4

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

end of thread, other threads:[~2016-08-23  2:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-17  7:05 [U-Boot] [PATCH v1] clk: clk-uclass: Check ops pointer before use it Wenyou Yang
2016-08-17 15:59 ` Stephen Warren
2016-08-18  0:30   ` Wenyou.Yang at microchip.com
2016-08-18  3:45     ` Stephen Warren
2016-08-18  3:53       ` Wenyou.Yang at microchip.com
2016-08-18  3:55         ` Stephen Warren
2016-08-19  1:49           ` Wenyou.Yang at microchip.com
2016-08-19  3:52             ` Stephen Warren
2016-08-21 16:54               ` Masahiro Yamada
2016-08-23  2:01                 ` Wenyou.Yang at microchip.com
2016-08-18  3:45   ` Simon Glass

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.