[PATCH] mux: drop superfluous null check
From: Josua Mayer
Date: Thu Apr 23 2026 - 11:37:39 EST
The internal helper function mux_get may return NULL for non-existent
muxes, only if the optional argument is true. Otherwise ERR_PTR is
returned.
The public mux_control_get function is not allowed to return NULL, and
must return a valid ERR_PTR for non-existent muxes.
Since mux_control_get uses mux_get with optional set false, there is no
need to check for the impossible outcome NULL.
Drop the unnecessary NULL check.
Fixes: 993bcaf32c49 ("mux: Add helper functions for getting optional and selected mux-state")
Reported-by: Dan Carpenter <error27@xxxxxxxxx>
Closes: https://lore.kernel.org/r/adjNEl0C8OgEjMI7@stanley.mountain
Signed-off-by: Josua Mayer <josua@xxxxxxxxxxxxx>
---
drivers/mux/core.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/mux/core.c b/drivers/mux/core.c
index 23538de2c91b4..9f124f4db8af2 100644
--- a/drivers/mux/core.c
+++ b/drivers/mux/core.c
@@ -635,12 +635,7 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name,
*/
struct mux_control *mux_control_get(struct device *dev, const char *mux_name)
{
- struct mux_control *mux = mux_get(dev, mux_name, NULL, false);
-
- if (!mux)
- return ERR_PTR(-ENOENT);
-
- return mux;
+ return mux_get(dev, mux_name, NULL, false);
}
EXPORT_SYMBOL_GPL(mux_control_get);
---
base-commit: 2e68039281932e6dc37718a1ea7cbb8e2cda42e6
change-id: 20260423-mux-smatch-fixup-be29cefca0b1
Best regards,
--
Josua Mayer <josua@xxxxxxxxxxxxx>