mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mux: drop superfluous null check
@ 2026-04-23 15:36 Josua Mayer
  0 siblings, 0 replies; only message in thread
From: Josua Mayer @ 2026-04-23 15:36 UTC (permalink / raw)
  To: Peter Rosin, Ulf Hansson, Wolfram Sang
  Cc: Dan Carpenter, linux-kernel, linux-kernel, Josua Mayer

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@gmail.com>
Closes: https://lore.kernel.org/r/adjNEl0C8OgEjMI7@stanley.mountain
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
 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@solid-run.com>


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-23 15:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-23 15:36 [PATCH] mux: drop superfluous null check Josua Mayer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®