diff mbox

[U-Boot,1/1] bcm281xx: clock: avoid possible NULL dereference

Message ID 20170730182716.8839-1-xypron.glpk@gmx.de
State Accepted
Commit 6def7de37ba2aeb3d59c561b288537d8c3712c73
Delegated to: Tom Rini
Headers show

Commit Message

Heinrich Schuchardt July 30, 2017, 6:27 p.m. UTC
It does not make sense first to dereference c and then
to check if it is NULL.

The problem was indicated by cppcheck.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 arch/arm/cpu/armv7/bcm281xx/clk-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Tom Rini Aug. 14, 2017, 12:07 a.m. UTC | #1
On Sun, Jul 30, 2017 at 08:27:16PM +0200, xypron.glpk@gmx.de wrote:

> It does not make sense first to dereference c and then
> to check if it is NULL.
> 
> The problem was indicated by cppcheck.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/bcm281xx/clk-core.c b/arch/arm/cpu/armv7/bcm281xx/clk-core.c
index cdc1264d7c..b061c20648 100644
--- a/arch/arm/cpu/armv7/bcm281xx/clk-core.c
+++ b/arch/arm/cpu/armv7/bcm281xx/clk-core.c
@@ -479,9 +479,9 @@  unsigned long clk_get_rate(struct clk *c)
 {
 	unsigned long rate;
 
-	debug("%s: %s\n", __func__, c->name);
 	if (!c || !c->ops || !c->ops->get_rate)
 		return 0;
+	debug("%s: %s\n", __func__, c->name);
 
 	rate = c->ops->get_rate(c);
 	debug("%s: rate = %ld\n", __func__, rate);
@@ -493,9 +493,9 @@  int clk_set_rate(struct clk *c, unsigned long rate)
 {
 	int ret;
 
-	debug("%s: %s rate=%ld\n", __func__, c->name, rate);
 	if (!c || !c->ops || !c->ops->set_rate)
 		return -EINVAL;
+	debug("%s: %s rate=%ld\n", __func__, c->name, rate);
 
 	if (c->use_cnt)
 		return -EINVAL;