From: Mikulas Patocka <mpato...@redhat.com> [ Upstream commit 6e11952a6abc4641dc8ae63f01b318b31b44e8db ]
If dm_register_path_selector, don't print the "version X loaded" message. Signed-off-by: Mikulas Patocka <mpato...@redhat.com> Signed-off-by: Sasha Levin <sas...@kernel.org> --- LLM Generated explanations, may be completely bogus: **Backport Status: YES** This commit is a clear candidate for backporting to stable kernel trees. Here's my extensive analysis: ## Bug Analysis The commit fixes a logic error in the error handling of four device- mapper path selector modules. Looking at the code changes: 1. **Original buggy behavior**: When `dm_register_path_selector()` fails (returns r < 0), the code would: - Print "register failed" error message - **Continue to print "version X loaded" message** - Return the error code 2. **Fixed behavior**: When registration fails: - Print "register failed" error message - **Return immediately with the error code** - Skip the misleading "loaded" message ## Why This Should Be Backported 1. **Clear Bug Fix**: This is a straightforward bug fix that corrects misleading log messages. When module registration fails, it incorrectly reports success with "version X loaded". 2. **Small and Contained**: The fix is minimal - just adding an early return statement in four similar init functions: - `dm_hst_init()` in dm-ps-historical-service-time.c - `dm_ql_init()` in dm-ps-queue-length.c - `dm_rr_init()` in dm-ps-round-robin.c - `dm_st_init()` in dm-ps-service-time.c 3. **No Side Effects**: The change only affects error path behavior and logging. It doesn't introduce new functionality or change any successful operation paths. 4. **User-Visible Issue**: This fixes a user-visible problem where system logs would incorrectly indicate a module loaded successfully when it actually failed. 5. **Consistent Pattern**: All four files have the identical bug and identical fix, showing this is a systematic issue that should be addressed. 6. **Low Risk**: The change is trivial - adding an early return on error. There's virtually no risk of regression since: - It only changes behavior when registration already failed - The function already returns the error code at the end - This just makes it return earlier without printing the misleading message 7. **Affects Core Subsystem**: Device-mapper is a critical storage subsystem, and accurate error reporting is important for system administrators debugging storage issues. The commit perfectly fits stable kernel criteria: it's a small, obvious fix for a real bug that affects users (through misleading log messages), with minimal risk of introducing new problems. drivers/md/dm-ps-historical-service-time.c | 4 +++- drivers/md/dm-ps-queue-length.c | 4 +++- drivers/md/dm-ps-round-robin.c | 4 +++- drivers/md/dm-ps-service-time.c | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-ps-historical-service-time.c b/drivers/md/dm-ps-historical-service-time.c index b49e10d76d03..2c8626a83de4 100644 --- a/drivers/md/dm-ps-historical-service-time.c +++ b/drivers/md/dm-ps-historical-service-time.c @@ -541,8 +541,10 @@ static int __init dm_hst_init(void) { int r = dm_register_path_selector(&hst_ps); - if (r < 0) + if (r < 0) { DMERR("register failed %d", r); + return r; + } DMINFO("version " HST_VERSION " loaded"); diff --git a/drivers/md/dm-ps-queue-length.c b/drivers/md/dm-ps-queue-length.c index e305f05ad1e5..eb543e6431e0 100644 --- a/drivers/md/dm-ps-queue-length.c +++ b/drivers/md/dm-ps-queue-length.c @@ -260,8 +260,10 @@ static int __init dm_ql_init(void) { int r = dm_register_path_selector(&ql_ps); - if (r < 0) + if (r < 0) { DMERR("register failed %d", r); + return r; + } DMINFO("version " QL_VERSION " loaded"); diff --git a/drivers/md/dm-ps-round-robin.c b/drivers/md/dm-ps-round-robin.c index d1745b123dc1..66a15ac0c22c 100644 --- a/drivers/md/dm-ps-round-robin.c +++ b/drivers/md/dm-ps-round-robin.c @@ -220,8 +220,10 @@ static int __init dm_rr_init(void) { int r = dm_register_path_selector(&rr_ps); - if (r < 0) + if (r < 0) { DMERR("register failed %d", r); + return r; + } DMINFO("version " RR_VERSION " loaded"); diff --git a/drivers/md/dm-ps-service-time.c b/drivers/md/dm-ps-service-time.c index 969d31c40272..f8c43aecdb27 100644 --- a/drivers/md/dm-ps-service-time.c +++ b/drivers/md/dm-ps-service-time.c @@ -341,8 +341,10 @@ static int __init dm_st_init(void) { int r = dm_register_path_selector(&st_ps); - if (r < 0) + if (r < 0) { DMERR("register failed %d", r); + return r; + } DMINFO("version " ST_VERSION " loaded"); -- 2.39.5