Page MenuHomeFreeBSD

LinuxKPI: Remove an unused local var fileid from the macro request_module
ClosedPublic

Authored by zlei on Apr 1 2024, 4:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, May 13, 7:37 AM
Unknown Object (File)
Sun, May 5, 8:22 AM
Unknown Object (File)
Sat, May 4, 5:10 AM
Unknown Object (File)
Apr 28 2024, 1:04 PM
Unknown Object (File)
Apr 26 2024, 11:28 PM
Unknown Object (File)
Apr 26 2024, 4:37 AM
Unknown Object (File)
Apr 17 2024, 4:58 PM
Unknown Object (File)
Apr 16 2024, 2:48 AM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

zlei requested review of this revision.Apr 1 2024, 4:38 PM

sure, there is no need to pass in a temporary variable just to discard the result

This revision is now accepted and ready to land.Apr 4 2024, 6:17 PM
bz added a subscriber: bz.

I don't know if the code path in drm_encoder_slave.c actually uses this; I hit it in iwlwifi yesterday and still have to investigate but having this run from kldloading a module made the system hang in a way that ^T did not work anymore on the console.

I don't know if the code path in drm_encoder_slave.c actually uses this

I don't think the change in this review should have any effect - we just go from discarding the returned fileid to not requesting it at all.

I don't know if the code path in drm_encoder_slave.c actually uses this

I don't think the change in this review should have any effect - we just go from discarding the returned fileid to not requesting it at all.

Yes, I understand; hence accepted. I was just curious how (and why) this got spotted given it's been sitting there like this for a decade. If there are (public) consumers I missed it would be good to know as I am still curious as to why it can hang a system (and if it does why has no one noticed it in the past; e.g. what the invariants are).

I was just curious how (and why) this got spotted given it's been sitting there like this for a decade.

Yeah, good point - I'm somewhat curious about that too.

In D44583#1017691, @bz wrote:

I don't know if the code path in drm_encoder_slave.c actually uses this

I don't think the change in this review should have any effect - we just go from discarding the returned fileid to not requesting it at all.

Yes, I understand; hence accepted. I was just curious how (and why) this got spotted given it's been sitting there like this for a decade. If there are (public) consumers I missed it would be good to know as I am still curious as to why it can hang a system (and if it does why has no one noticed it in the past; e.g. what the invariants are).

I was just curious how (and why) this got spotted given it's been sitting there like this for a decade.

Yeah, good point - I'm somewhat curious about that too.

I spotted this while working on D44581 which intends to introduce new kernel-only error code and on D44552 which uses it.

Why it is not spotted and is been sitting there like this for a decade, I'm not sure but I guess kern_kldload() is public and we are passing reference of the on-stack var and compilers (I tested gcc 13.2 and clang 18, with -Wall -Wunused-variable) can NOT infer if kern_kldload () has any side effect thus they hesitate to give a warn message.

As for

why it can hang a system

I have no idea but I'm recently working on kernel linkers so I'm interested with it. May you please share the steps to repeat ?

I spotted this while working on D44581 which intends to introduce new kernel-only error code EUNSDEP and on D44552 which uses it.

As in D44552 kern_kldload() will return the new error. It should not be leaked to the userspace. I was evaluating the impact and @olce pointed out the macro request_module is consuming kern_kldload().