Skip to contentSkip to conversation

CLK: TI: consider the fact that of_clk_get() might return an error

PATCH Superseded Sebastian Andrzej Siewior 3 participants 6 messages Sep 11, 2014 – Sep 29, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CLK: TI: consider the fact that of_clk_get() might return an error

I "forgot" to update the dtb and the kernel crashed:

|Unable to handle kernel NULL pointer dereference at virtual address 0000002e
|PC is at __clk_get_flags+0x4/0xc
|LR is at ti_dt_clockdomains_setup+0x70/0xe8

because I did not have the clock nodes. of_clk_get() returns an error pointer which is not checked here.

---
 drivers/clk/ti/clockdomain.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/clk/ti/clockdomain.c +5 -0
index f1e0038d76ac..fdd458600c2c 100644
@@ -36,6 +36,11 @@ static void __init of_ti_clockdomain_setup(struct device_node *node)
 
 	for (i = 0; i < num_clks; i++) {
 		clk = of_clk_get(node, i);
+		if (IS_ERR(clk)) {
+			pr_err("Failed get %s' clock nr %d (%ld)\n",
+					node->full_name, i, PTR_ERR(clk));
+			continue;
+		}
 		if (__clk_get_flags(clk) & CLK_IS_BASIC) {
 			pr_warn("can't setup clkdm for basic clk %s\n",
 				__clk_get_name(clk));
Signature · 1 line
2.1.0
#1 lore raw
Quoted 18 lines · Sebastian Andrzej Siewior

I "forgot" to update the dtb and the kernel crashed:

|Unable to handle kernel NULL pointer dereference at virtual address 0000002e
|PC is at __clk_get_flags+0x4/0xc
|LR is at ti_dt_clockdomains_setup+0x70/0xe8

because I did not have the clock nodes. of_clk_get() returns an error pointer which is not checked here.

---
  drivers/clk/ti/clockdomain.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/clk/ti/clockdomain.c +0 -0
index f1e0038d76ac..fdd458600c2c 100644

drivers/clk/ti/clockdomain.c static void __init of_ti_clockdomain_setup(struct device_node *node) · line 41

Quoted 6 lines
drivers/clk/ti/clockdomain.c +3 -0
@@ -36,6 +36,11 @@ static void __init of_ti_clockdomain_setup(struct device_node *node)
 
  	for (i = 0; i < num_clks; i++) {
  		clk = of_clk_get(node, i);
+		if (IS_ERR(clk)) {
+			pr_err("Failed get %s' clock nr %d (%ld)\n",
+					node->full_name, i, PTR_ERR(clk));

Could you add %s: __func__ as well - it kinda helps understand this is part of clockdomain setup and not some driver cribbing that it did not get some clock.

Quoted 6 lines
drivers/clk/ti/clockdomain.c +2 -0
+			continue;
+		}
  		if (__clk_get_flags(clk) & CLK_IS_BASIC) {
  			pr_warn("can't setup clkdm for basic clk %s\n",
  				__clk_get_name(clk));
#2 lore raw

PATCH v2 1/1 CLK: TI: consider the fact that of_clk_get() might return an error

I "forgot" to update the dtb and the kernel crashed:

|Unable to handle kernel NULL pointer dereference at virtual address 0000002e
|PC is at __clk_get_flags+0x4/0xc
|LR is at ti_dt_clockdomains_setup+0x70/0xe8

because I did not have the clock nodes. of_clk_get() returns an error pointer which is not checked here.

---
v1…v2:
add "%s __func__" to the added pr_err

Quoted 4 lines · * Nishanth Menon | 2014-09-17 07:52:33 [-0500]:

Could you add %s: __func__ as well - it kinda helps understand this is part of clockdomain setup and not some driver cribbing that it did not get some clock.

As you wish.

 drivers/clk/ti/clockdomain.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/clk/ti/clockdomain.c +6 -0
index f1e0038d76ac..446481166ce9 100644
@@ -36,6 +36,12 @@ static void __init of_ti_clockdomain_setup(struct device_node *node)
 
 	for (i = 0; i < num_clks; i++) {
 		clk = of_clk_get(node, i);
+		if (IS_ERR(clk)) {
+			pr_err("%s: Failed get %s' clock nr %d (%ld)\n",
+					__func__, node->full_name, i,
+					PTR_ERR(clk));
+			continue;
+		}
 		if (__clk_get_flags(clk) & CLK_IS_BASIC) {
 			pr_warn("can't setup clkdm for basic clk %s\n",
 				__clk_get_name(clk));
Signature · 5 lines
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by on v2 1/1
#3 lore raw
Quoted 29 lines · Sebastian Andrzej Siewior

I "forgot" to update the dtb and the kernel crashed:

|Unable to handle kernel NULL pointer dereference at virtual address 0000002e
|PC is at __clk_get_flags+0x4/0xc
|LR is at ti_dt_clockdomains_setup+0x70/0xe8

because I did not have the clock nodes. of_clk_get() returns an error pointer which is not checked here.

---
v1…v2:
add "%s __func__" to the added pr_err

Quoted 4 lines · * Nishanth Menon | 2014-09-17 07:52:33 [-0500]:

Could you add %s: __func__ as well - it kinda helps understand this is part of clockdomain setup and not some driver cribbing that it did not get some clock.

As you wish.

 drivers/clk/ti/clockdomain.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/clk/ti/clockdomain.c +0 -0
index f1e0038d76ac..446481166ce9 100644

drivers/clk/ti/clockdomain.c static void __init of_ti_clockdomain_setup(struct device_node *node) · line 44

Quoted 9 lines
drivers/clk/ti/clockdomain.c +6 -0
@@ -36,6 +36,12 @@ static void __init of_ti_clockdomain_setup(struct device_node *node)
 
 	for (i = 0; i < num_clks; i++) {
 		clk = of_clk_get(node, i);
+		if (IS_ERR(clk)) {
+			pr_err("%s: Failed get %s' clock nr %d (%ld)\n",
+					__func__, node->full_name, i,
+					PTR_ERR(clk));
+			continue;
+		}

Once the following is fixed (checkpatch --strict) feel free to add:

#65: FILE: drivers/clk/ti/clockdomain.c:35:
_node *node)

CHECK: Alignment should match open parenthesis
#71: FILE: drivers/clk/ti/clockdomain.c:40:
+ pr_err("%s: Failed get %s' clock nr %d (%ld)\n",
+ __func__, node->full_name, i,

total: 1 errors, 0 warnings, 1 checks, 16 lines checked

If any of these errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.

Signature · 6 lines
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

PATCH v3 1/1 CLK: TI: consider the fact that of_clk_get() might return an error

I "forgot" to update the dtb and the kernel crashed:

|Unable to handle kernel NULL pointer dereference at virtual address 0000002e
|PC is at __clk_get_flags+0x4/0xc
|LR is at ti_dt_clockdomains_setup+0x70/0xe8

because I did not have the clock nodes. of_clk_get() returns an error pointer which is not checked here.

---
v2?v3:
- added acked by
- fixed "CHECK: Alignment should match open parenthesis"

v1?v2:
add "%s __func__" to the added pr_err

 drivers/clk/ti/clockdomain.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/clk/ti/clockdomain.c +5 -0
index f1e0038d76ac..b4c5faccaece 100644
@@ -36,6 +36,11 @@ static void __init of_ti_clockdomain_setup(struct device_node *node)
 
 	for (i = 0; i < num_clks; i++) {
 		clk = of_clk_get(node, i);
+		if (IS_ERR(clk)) {
+			pr_err("%s: Failed get %s' clock nr %d (%ld)\n",
+			       __func__, node->full_name, i, PTR_ERR(clk));
+			continue;
+		}
 		if (__clk_get_flags(clk) & CLK_IS_BASIC) {
 			pr_warn("can't setup clkdm for basic clk %s\n",
 				__clk_get_name(clk));
Signature · 1 line
2.1.0
#5 lore raw

PATCH v3 1/1 CLK: TI: consider the fact that of_clk_get() might return an error

Quoted 10 lines · Sebastian Andrzej Siewior

I "forgot" to update the dtb and the kernel crashed:

|Unable to handle kernel NULL pointer dereference at virtual address 0000002e
|PC is at __clk_get_flags+0x4/0xc
|LR is at ti_dt_clockdomains_setup+0x70/0xe8

because I did not have the clock nodes. of_clk_get() returns an error pointer which is not checked here.

Thanks, v3 applied to for-v3.18/ti-clk-drv.

-Tero

Quoted 18 lines

---
v2…v3:
- added acked by
- fixed "CHECK: Alignment should match open parenthesis"

v1…v2:
add "%s __func__" to the added pr_err

  drivers/clk/ti/clockdomain.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/clk/ti/clockdomain.c +0 -0
index f1e0038d76ac..b4c5faccaece 100644
@@ -36,6 +36,11 @@ static void __init of_ti_clockdomain_setup(struct device_node *node)
 

drivers/clk/ti/clockdomain.c static void __init of_ti_clockdomain_setup(struct device_node *node) · line 46

Quoted 10 lines
drivers/clk/ti/clockdomain.c +5 -0
  	for (i = 0; i < num_clks; i++) {
  		clk = of_clk_get(node, i);
+		if (IS_ERR(clk)) {
+			pr_err("%s: Failed get %s' clock nr %d (%ld)\n",
+			       __func__, node->full_name, i, PTR_ERR(clk));
+			continue;
+		}
  		if (__clk_get_flags(clk) & CLK_IS_BASIC) {
  			pr_warn("can't setup clkdm for basic clk %s\n",
  				__clk_get_name(clk));

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html