Skip to contentSkip to conversation

powerpc/ps3: Fix error return code in ps3_register_devices()

PATCH In review Zhen Lei 3 participants 4 messages May 18, 2021 – May 24, 2021

Subsystems (2)
lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 powerpc/ps3: Fix error return code in ps3_register_devices()

When call ps3_start_probe_thread() failed, further initialization should be stopped and the returned error code should be propagated.

---
 arch/powerpc/platforms/ps3/device-init.c | 2 ++
 1 file changed, 2 insertions(+)
arch/powerpc/platforms/ps3/device-init.c +2 -0
index e87360a0fb40..9b6d8ca8fc01 100644
@@ -955,6 +955,8 @@ static int __init ps3_register_devices(void)
 	/* ps3_repository_dump_bus_info(); */
 
 	result = ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE);
+	if (result < 0)
+		return result;
 
 	ps3_register_vuart_devices();
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines · Zhen Lei

When call ps3_start_probe_thread() failed, further initialization should be stopped and the returned error code should be propagated.

It's not clear to me that's a good change.

arch/powerpc/platforms/ps3/device-init.c static int __init ps3_register_devices(void) · line 959

Quoted 10 lines
arch/powerpc/platforms/ps3/device-init.c +2 -0
index e87360a0fb40..9b6d8ca8fc01 100644
@@ -955,6 +955,8 @@ static int __init ps3_register_devices(void)
 	/* ps3_repository_dump_bus_info(); */
 
 	result = ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE);
+	if (result < 0)
+		return result;

If you bail out here you skip:

arch/powerpc/platforms/ps3/device-init.c static int __init ps3_register_devices(void) · line 961

Quoted 1 line
arch/powerpc/platforms/ps3/device-init.c +0 -0
 	ps3_register_vuart_devices();

Which I suspect means there will be no console output?

Presumably the system won't boot if the probe thread fails, but it might at least print an oops, whereas if we return we might get nothing at all. Though I'm just guessing, I don't know this code that well.

Anyway please leave this code alone unless you're willing to test your changes, or at least provide a more thorough justification for them.

cheers

maintainer
#2 lore raw

Hi,

Quoted 3 lines · Michael Ellerman
Quoted 2 lines · Zhen Lei

When call ps3_start_probe_thread() failed, further initialization should be stopped and the returned error code should be propagated.

...

Quoted 8 lines

arch/powerpc/platforms/ps3/device-init.c static int __init ps3_register_devices(void) · line 959

Quoted 5 lines

--- a/arch/powerpc/platforms/ps3/device-init.c

arch/powerpc/platforms/ps3/device-init.c +2 -0
 	result = ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE);
+	if (result < 0)
+		return result;

If you bail out here you skip:

Quoted 7 lines
Quoted 1 line

ps3_register_vuart_devices();

Which I suspect means there will be no console output?

Presumably the system won't boot if the probe thread fails, but it might at least print an oops, whereas if we return we might get nothing at all. Though I'm just guessing, I don't know this code that well.

That probe is for the storage devices (PS3_BUS_TYPE_STORAGE).

There are cases where the system is usable even if the storage devices are not available, for example, when using an NFS root filesystem.

ps3_start_probe_thread was made to be quite verbose on error to make up for it's return value not being checked.

Quoted 2 lines

Anyway please leave this code alone unless you're willing to test your changes, or at least provide a more thorough justification for them.

Agreed, this change should not be merged.

-Geoff

#3 lore raw
Quoted 23 lines · Geoff Levand

Hi,

Quoted 3 lines · Michael Ellerman
Quoted 2 lines · Zhen Lei

When call ps3_start_probe_thread() failed, further initialization should be stopped and the returned error code should be propagated.

...

Quoted 8 lines

arch/powerpc/platforms/ps3/device-init.c static int __init ps3_register_devices(void) · line 959

Quoted 5 lines

--- a/arch/powerpc/platforms/ps3/device-init.c

arch/powerpc/platforms/ps3/device-init.c +2 -0
 	result = ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE);
+	if (result < 0)
+		return result;

If you bail out here you skip:

Quoted 7 lines
Quoted 1 line

ps3_register_vuart_devices();

Which I suspect means there will be no console output?

Presumably the system won't boot if the probe thread fails, but it might at least print an oops, whereas if we return we might get nothing at all. Though I'm just guessing, I don't know this code that well.

Quoted 8 lines

That probe is for the storage devices (PS3_BUS_TYPE_STORAGE).

There are cases where the system is usable even if the storage devices are not available, for example, when using an NFS root filesystem.

ps3_start_probe_thread was made to be quite verbose on error to make up for it's return value not being checked.

So should we delete the local variable 'result' and ignore the return value?
- result = ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE);
- (void)ps3_start_probe_thread(PS3_BUS_TYPE_STORAGE);

Quoted 10 lines
Quoted 3 lines

Anyway please leave this code alone unless you're willing to test your changes, or at least provide a more thorough justification for them.

Agreed, this change should not be merged.

-Geoff

.