Skip to contentSkip to conversation

clk: versaclock: Fix incorrect error check in versaclock_probe()

PATCH In review Kuan-Wei Chiu 2 participants 3 messages Dec 12, 2025 – Apr 7 Common clk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: versaclock: Fix incorrect error check in versaclock_probe()

The error check during the registration of FODs is incorrect. The code currently checks IS_ERR(pll_name) immediately after assigning fod_name[n].

Since pll_name is checked in a previous block, this condition will always be false, causing any allocation failure in versaclock_get_name() for fod_name to be ignored. This could lead to usage of an invalid pointer.

Fix the condition to check fod_name[n] instead.

Fixes dcf2cee77f2d ("clk: clk_versaclock: Add support for versaclock driver")
---
 drivers/clk/clk_versaclock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk_versaclock.c +1 -1
index 19a787eaf0c..1dbde75f180 100644
@@ -945,7 +945,7 @@ int versaclock_probe(struct udevice *dev)
 	/* Register FODs */
 	for (n = 0; n < vc5->chip_info->clk_fod_cnt; n++) {
 		fod_name[n] = versaclock_get_name(dev->name, "fod", n);
-		if (IS_ERR(pll_name)) {
+		if (IS_ERR(fod_name[n])) {
 			ret = PTR_ERR(fod_name[n]);
 			goto free_fod;
 		}
Signature · 1 line
2.52.0.239.gd5f0c6e74e-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Kuan-Wei Chiu

The error check during the registration of FODs is incorrect. The code currently checks IS_ERR(pll_name) immediately after assigning fod_name[n].

Since pll_name is checked in a previous block, this condition will always be false, causing any allocation failure in versaclock_get_name() for fod_name to be ignored. This could lead to usage of an invalid pointer.

Fix the condition to check fod_name[n] instead.

Fixes dcf2cee77f2d ("clk: clk_versaclock: Add support for versaclock driver")
---
 drivers/clk/clk_versaclock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk_versaclock.c +0 -0
index 19a787eaf0c..1dbde75f180 100644

drivers/clk/clk_versaclock.c int versaclock_probe(struct udevice *dev) · line 951

Quoted 8 lines
drivers/clk/clk_versaclock.c +1 -1
@@ -945,7 +945,7 @@ int versaclock_probe(struct udevice *dev)
      /* Register FODs */
      for (n = 0; n < vc5->chip_info->clk_fod_cnt; n++) {
              fod_name[n] = versaclock_get_name(dev->name, "fod", n);
-             if (IS_ERR(pll_name)) {
+             if (IS_ERR(fod_name[n])) {
                      ret = PTR_ERR(fod_name[n]);
                      goto free_fod;
              }

[CES 2026, SECO]<https://exhibitors.ces.tech/8_0/exhibitor/exhibitor-details.cfm?exhid=001Pp000010EbaOIAS>

#2 lore raw
Quoted 18 lines · Sean Anderson
Quoted 17 lines · Kuan-Wei Chiu

The error check during the registration of FODs is incorrect. The code currently checks IS_ERR(pll_name) immediately after assigning fod_name[n].

Since pll_name is checked in a previous block, this condition will always be false, causing any allocation failure in versaclock_get_name() for fod_name to be ignored. This could lead to usage of an invalid pointer.

Fix the condition to check fod_name[n] instead.

Fixes dcf2cee77f2d ("clk: clk_versaclock: Add support for versaclock driver")
---
 drivers/clk/clk_versaclock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

drivers/clk/clk_versaclock.c int versaclock_probe(struct udevice *dev) · line 951

Quoted 13 lines
drivers/clk/clk_versaclock.c +1 -1
index 19a787eaf0c..1dbde75f180 100644
@@ -945,7 +945,7 @@ int versaclock_probe(struct udevice *dev)
      /* Register FODs */
      for (n = 0; n < vc5->chip_info->clk_fod_cnt; n++) {
              fod_name[n] = versaclock_get_name(dev->name, "fod", n);
-             if (IS_ERR(pll_name)) {
+             if (IS_ERR(fod_name[n])) {
                      ret = PTR_ERR(fod_name[n]);
                      goto free_fod;
              }

Thanks for the review!

Just a gentle ping on this patch from last December. It looks like it might have slipped through the cracks.

Regards,
Kuan-Wei