Skip to contentSkip to conversation

ARM: zii-commmon: Fix NULL pointer dereference in do_rdu1_switch_reset()

PATCH Applied Andrey Smirnov 3 participants 3 messages Oct 30, 2019 – Nov 4, 2019 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: zii-commmon: Fix NULL pointer dereference in do_rdu1_switch_reset()

We need to go to parent's private data to get a pointer to struct rave_sp. Fix that.

Fixes 493e2ee38f ("ARM: zii-common: add support for switch reset on RDU1")
---
 arch/arm/boards/zii-common/switch-cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boards/zii-common/switch-cmd.c +1 -1
index 30438053a1..2b9c34bfac 100644
@@ -42,7 +42,7 @@ static int do_rdu2_switch_reset(void)
 static int do_rdu1_switch_reset(void)
 {
 	struct device_d *sp_dev = get_device_by_name("sp");
-	struct rave_sp *sp = sp_dev->priv;
+	struct rave_sp *sp = sp_dev->parent->priv;
 	u8 cmd[] = {
 		[0] = RAVE_SP_CMD_RESET_ETH_SWITCH,
 		[1] = 0
Signature · 7 lines
2.21.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Andrey Smirnov

We need to go to parent's private data to get a pointer to struct rave_sp. Fix that.

Fixes 493e2ee38f ("ARM: zii-common: add support for switch reset on RDU1")

Urgh, I remember that I fixed the very same bug some time ago. Seems I lost that fixup before upstreaming...

Quoted 9 lines
---
 arch/arm/boards/zii-common/switch-cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boards/zii-common/switch-cmd.c +0 -0
index 30438053a1..2b9c34bfac 100644

arch/arm/boards/zii-common/switch-cmd.c static int do_rdu2_switch_reset(void) · line 48

Quoted 8 lines
arch/arm/boards/zii-common/switch-cmd.c +1 -1
@@ -42,7 +42,7 @@ static int do_rdu2_switch_reset(void)
 static int do_rdu1_switch_reset(void)
 {
 	struct device_d *sp_dev = get_device_by_name("sp");
-	struct rave_sp *sp = sp_dev->priv;
+	struct rave_sp *sp = sp_dev->parent->priv;
 	u8 cmd[] = {
 		[0] = RAVE_SP_CMD_RESET_ETH_SWITCH,
 		[1] = 0

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Applied
#2 lore raw
In reply to Andrey Smirnov
Quoted 8 lines · Andrey Smirnov

We need to go to parent's private data to get a pointer to struct rave_sp. Fix that.

Fixes 493e2ee38f ("ARM: zii-common: add support for switch reset on RDU1")
---
 arch/arm/boards/zii-common/switch-cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox