Skip to contentSkip to conversation

bus: fsl-mc: Fix test for end of loop

PATCH In review Dan Carpenter 2 participants 5 messages Feb 1, 2021 – Feb 8, 2021

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

PATCH 1/1 bus: fsl-mc: Fix test for end of loop

The "desc" pointer can't possibly be NULL here. If we can't find the correct "desc" then tt points to the last element of the fsl_mc_accepted_cmds[] array. Fix this by testing if
"i = FSL_MC_NUM_ACCEPTED_CMDS" instead.

Fixes 2cf1e703f066 ("bus: fsl-mc: add fsl-mc userspace support")
---
 drivers/bus/fsl-mc/fsl-mc-uapi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/fsl-mc/fsl-mc-uapi.c +1 -1
index eeb988c9f4bb..bdcd9d983a78 100644
@@ -338,7 +338,7 @@ static int fsl_mc_command_check(struct fsl_mc_device *mc_dev,
 		if ((cmdid & desc->cmdid_mask) = desc->cmdid_value)
 			break;
 	}
-	if (!desc) {
+	if (i = FSL_MC_NUM_ACCEPTED_CMDS) {
 		dev_err(&mc_dev->dev, "MC command 0x%04x: cmdid not accepted\n", cmdid);
 		return -EACCES;
 	}
Signature · 1 line
2.29.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Dan Carpenter

The "desc" pointer can't possibly be NULL here. If we can't find the correct "desc" then tt points to the last element of the fsl_mc_accepted_cmds[] array. Fix this by testing if
"i == FSL_MC_NUM_ACCEPTED_CMDS" instead.

Fixes 2cf1e703f066 ("bus: fsl-mc: add fsl-mc userspace support")

Thanks!

Quoted 20 lines
---
 drivers/bus/fsl-mc/fsl-mc-uapi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/fsl-mc/fsl-mc-uapi.c +1 -1
index eeb988c9f4bb..bdcd9d983a78 100644
@@ -338,7 +338,7 @@ static int fsl_mc_command_check(struct fsl_mc_device *mc_dev,
 		if ((cmdid & desc->cmdid_mask) == desc->cmdid_value)
 			break;
 	}
-	if (!desc) {
+	if (i == FSL_MC_NUM_ACCEPTED_CMDS) {
 		dev_err(&mc_dev->dev, "MC command 0x%04x: cmdid not accepted\n", cmdid);
 		return -EACCES;
 	}
Signature · 1 line
2.29.2
maintainer
#2 lore raw
In reply to Dan Carpenter
Quoted 7 lines · Dan Carpenter

The "desc" pointer can't possibly be NULL here. If we can't find the correct "desc" then tt points to the last element of the fsl_mc_accepted_cmds[] array. Fix this by testing if
"i == FSL_MC_NUM_ACCEPTED_CMDS" instead.

Fixes 2cf1e703f066 ("bus: fsl-mc: add fsl-mc userspace support")

Hi,

I just noticed that Greg wasn't copied on the initial email.

If you don't mind I will re-submit your patch along with other updates to the fsl-mc bus so that you don't have to bother.

Ioana

Quoted 20 lines
---
 drivers/bus/fsl-mc/fsl-mc-uapi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/fsl-mc/fsl-mc-uapi.c +1 -1
index eeb988c9f4bb..bdcd9d983a78 100644
@@ -338,7 +338,7 @@ static int fsl_mc_command_check(struct fsl_mc_device *mc_dev,
 		if ((cmdid & desc->cmdid_mask) == desc->cmdid_value)
 			break;
 	}
-	if (!desc) {
+	if (i == FSL_MC_NUM_ACCEPTED_CMDS) {
 		dev_err(&mc_dev->dev, "MC command 0x%04x: cmdid not accepted\n", cmdid);
 		return -EACCES;
 	}
Signature · 1 line
2.29.2
#3 lore raw
Quoted 9 lines · Ioana Ciornei
Quoted 7 lines · Dan Carpenter

The "desc" pointer can't possibly be NULL here. If we can't find the correct "desc" then tt points to the last element of the fsl_mc_accepted_cmds[] array. Fix this by testing if
"i = FSL_MC_NUM_ACCEPTED_CMDS" instead.

Fixes 2cf1e703f066 ("bus: fsl-mc: add fsl-mc userspace support")
Quoted 7 lines

Hi,

I just noticed that Greg wasn't copied on the initial email.

If you don't mind I will re-submit your patch along with other updates to the fsl-mc bus so that you don't have to bother.

Thanks for doing that!

Was Greg supposed to have been copied, though? He's not listed in the ./scripts/get_maintainer.pl output.

regards,
dan carpenter

maintainer
#4 lore raw
Quoted 14 lines · Dan Carpenter
Quoted 13 lines · Ioana Ciornei
Quoted 7 lines · Dan Carpenter

The "desc" pointer can't possibly be NULL here. If we can't find the correct "desc" then tt points to the last element of the fsl_mc_accepted_cmds[] array. Fix this by testing if
"i == FSL_MC_NUM_ACCEPTED_CMDS" instead.

Fixes 2cf1e703f066 ("bus: fsl-mc: add fsl-mc userspace support")

Hi,

I just noticed that Greg wasn't copied on the initial email.

Quoted 9 lines
Quoted 3 lines

If you don't mind I will re-submit your patch along with other updates to the fsl-mc bus so that you don't have to bother.

Thanks for doing that!

Was Greg supposed to have been copied, though? He's not listed in the ./scripts/get_maintainer.pl output.

Huh, he's not listed indeed. I didn't check this before since the fsl-mc bus changes have always been pushed through Greg's char-misc tree.