Skip to contentSkip to conversation

bus: mvebu-mbus: potential forever loop in mvebu_mbus_init()

PATCH In review Dan Carpenter 3 participants 7 messages Nov 13, 2013 – Nov 24, 2013

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

PATCH 1/1 bus: mvebu-mbus: potential forever loop in mvebu_mbus_init()

"of_id->compatible" is an array and not a pointer so it can never be NULL.

---
I'm not able to compile this.

drivers/bus/mvebu-mbus.c +2 -2
index 2394e97..c646a76 100644
@@ -734,11 +734,11 @@ int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base,
 {
 	const struct of_device_id *of_id;
 
-	for (of_id = of_mvebu_mbus_ids; of_id->compatible; of_id++)
+	for (of_id = of_mvebu_mbus_ids; of_id->compatible[0]; of_id++)
 		if (!strcmp(of_id->compatible, soc))
 			break;
 
-	if (!of_id->compatible) {
+	if (!of_id->compatible[0]) {
 		pr_err("could not find a matching SoC family\n");
 		return -ENODEV;
 	}
#1 lore raw

Dan,

Quoted 2 lines · Dan Carpenter

"of_id->compatible" is an array and not a pointer so it can never be NULL.

Thanks for pointing this out.

Quoted 9 lines

---
I'm not able to compile this.

drivers/bus/mvebu-mbus.c +0 -0
index 2394e97..c646a76 100644

drivers/bus/mvebu-mbus.c int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base, · line 739

Quoted 7 lines
drivers/bus/mvebu-mbus.c +1 -1
@@ -734,11 +734,11 @@ int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base,
 {
 	const struct of_device_id *of_id;
 
-	for (of_id = of_mvebu_mbus_ids; of_id->compatible; of_id++)
+	for (of_id = of_mvebu_mbus_ids; of_id->compatible[0]; of_id++)
 		if (!strcmp(of_id->compatible, soc))
 			break;

Ezequiel et al,

The comment above the declaration for of_mvebu_mbus_ids says:

/*
* The driver doesn't yet have a DT binding because the details of
* this DT binding still need to be sorted out. However, as a
* preparation, we already use of_device_id to match a SoC description
* string against the SoC specific details of this driver. */

I believe we have a binding now. ;-) Care to look this over and provide a more complete cleanup patch?

thx,

Jason.

Acked-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 15 lines · Dan Carpenter

"of_id->compatible" is an array and not a pointer so it can never be NULL.

---
I'm not able to compile this.

drivers/bus/mvebu-mbus.c +0 -0
index 2394e97..c646a76 100644
@@ -734,11 +734,11 @@ int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base,
 {
 	const struct of_device_id *of_id;
 

drivers/bus/mvebu-mbus.c int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base, · line 744

Quoted 10 lines
drivers/bus/mvebu-mbus.c +2 -2
-	for (of_id = of_mvebu_mbus_ids; of_id->compatible; of_id++)
+	for (of_id = of_mvebu_mbus_ids; of_id->compatible[0]; of_id++)
 		if (!strcmp(of_id->compatible, soc))
 			break;
 
-	if (!of_id->compatible) {
+	if (!of_id->compatible[0]) {
 		pr_err("could not find a matching SoC family\n");
 		return -ENODEV;
 	}

Nice catch.

Just for the sake of it, I reproduced the bug, and then tested it's solved by the patch. The issue only hits the old platforms that aren't converted to DT.

IMHO, this is a "potential" bug, trigerred only if the code itself is wrong (which is not) and it's not serious enough to hit stable.

Signature · 7 lines
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
In reply to Dan Carpenter
Quoted 36 lines · Jason Cooper

Dan,

Quoted 2 lines · Dan Carpenter

"of_id->compatible" is an array and not a pointer so it can never be NULL.

Thanks for pointing this out.

Quoted 9 lines

---
I'm not able to compile this.

drivers/bus/mvebu-mbus.c +0 -0
index 2394e97..c646a76 100644

drivers/bus/mvebu-mbus.c int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base, · line 739

Quoted 7 lines
drivers/bus/mvebu-mbus.c +1 -1
@@ -734,11 +734,11 @@ int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base,
 {
 	const struct of_device_id *of_id;
 
-	for (of_id = of_mvebu_mbus_ids; of_id->compatible; of_id++)
+	for (of_id = of_mvebu_mbus_ids; of_id->compatible[0]; of_id++)
 		if (!strcmp(of_id->compatible, soc))
 			break;

Ezequiel et al,

The comment above the declaration for of_mvebu_mbus_ids says:

/*
* The driver doesn't yet have a DT binding because the details of
* this DT binding still need to be sorted out. However, as a
* preparation, we already use of_device_id to match a SoC description
* string against the SoC specific details of this driver. */

Quoted 3 lines

I believe we have a binding now. ;-) Care to look this over and provide a more complete cleanup patch?

Sure.

Signature · 7 lines
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
In reply to Dan Carpenter
Quoted 29 lines · Ezequiel Garcia
Quoted 15 lines · Dan Carpenter

"of_id->compatible" is an array and not a pointer so it can never be NULL.

---
I'm not able to compile this.

drivers/bus/mvebu-mbus.c +0 -0
index 2394e97..c646a76 100644
@@ -734,11 +734,11 @@ int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base,
 {
 	const struct of_device_id *of_id;
 

drivers/bus/mvebu-mbus.c int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base, · line 744

Quoted 10 lines
drivers/bus/mvebu-mbus.c +2 -2
-	for (of_id = of_mvebu_mbus_ids; of_id->compatible; of_id++)
+	for (of_id = of_mvebu_mbus_ids; of_id->compatible[0]; of_id++)
 		if (!strcmp(of_id->compatible, soc))
 			break;
 
-	if (!of_id->compatible) {
+	if (!of_id->compatible[0]) {
 		pr_err("could not find a matching SoC family\n");
 		return -ENODEV;
 	}

Nice catch.

Quoted 6 lines

Just for the sake of it, I reproduced the bug, and then tested it's solved by the patch. The issue only hits the old platforms that aren't converted to DT.

Jason:

FWIW, in case you've missed this mail, I tested this when Dan reported it. See above.

Signature · 7 lines
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw
In reply to Dan Carpenter
Quoted 34 lines · Ezequiel Garcia
Quoted 33 lines · Ezequiel Garcia
Quoted 15 lines · Dan Carpenter

"of_id->compatible" is an array and not a pointer so it can never be NULL.

---
I'm not able to compile this.

drivers/bus/mvebu-mbus.c +0 -0
index 2394e97..c646a76 100644
@@ -734,11 +734,11 @@ int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base,
 {
 	const struct of_device_id *of_id;
 

drivers/bus/mvebu-mbus.c int __init mvebu_mbus_init(const char *soc, phys_addr_t mbuswins_phys_base, · line 744

Quoted 10 lines
drivers/bus/mvebu-mbus.c +2 -2
-	for (of_id = of_mvebu_mbus_ids; of_id->compatible; of_id++)
+	for (of_id = of_mvebu_mbus_ids; of_id->compatible[0]; of_id++)
 		if (!strcmp(of_id->compatible, soc))
 			break;
 
-	if (!of_id->compatible) {
+	if (!of_id->compatible[0]) {
 		pr_err("could not find a matching SoC family\n");
 		return -ENODEV;
 	}

Nice catch.

Just for the sake of it, I reproduced the bug, and then tested it's solved by the patch. The issue only hits the old platforms that aren't converted to DT.

Quoted 7 lines
Quoted 2 lines

Jason:

FWIW, in case you've missed this mail, I tested this when Dan reported it. See above.

Fixed. Sorry I missed that.

thx,

Jason.