[PATCH] drm/bridge: Avoid uninitialized variable warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This works, but technically it uses "num_in_bus_fmts" before it has been
initialized so it leads to static checker warnings and probably KMEMsan
warnings at run time.  Reverse the checks so it checks for failure first
and then check for unsupported formats next.

Fixes: f32df58acc68 ("drm/bridge: Add the necessary bits to support bus format negotiation")
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
 drivers/gpu/drm/drm_bridge.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index e275b4ca344b..00cbde654472 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -897,10 +897,10 @@ static int select_bus_fmt_recursive(struct drm_bridge *first_bridge,
 							conn_state,
 							out_bus_fmt,
 							&num_in_bus_fmts);
-	if (!num_in_bus_fmts)
-		return -ENOTSUPP;
-	else if (!in_bus_fmts)
+	if (!in_bus_fmts)
 		return -ENOMEM;
+	else if (!num_in_bus_fmts)
+		return -ENOTSUPP;
 
 	if (first_bridge == cur_bridge) {
 		cur_state->input_bus_cfg.format = in_bus_fmts[0];
@@ -993,10 +993,10 @@ drm_atomic_bridge_chain_select_bus_fmts(struct drm_bridge *bridge,
 							crtc_state,
 							conn_state,
 							&num_out_bus_fmts);
-		if (!num_out_bus_fmts)
-			return -ENOTSUPP;
-		else if (!out_bus_fmts)
+		if (!out_bus_fmts)
 			return -ENOMEM;
+		else if (!num_out_bus_fmts)
+			return -ENOTSUPP;
 	} else {
 		num_out_bus_fmts = 1;
 		out_bus_fmts = kmalloc(sizeof(*out_bus_fmts), GFP_KERNEL);
-- 
2.35.1




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux