diff mbox series

[v2] drm/bridge: Avoid uninitialized variable warning

Message ID YrrIs3hoGcPVmXc5@kili (mailing list archive)
State New, archived
Headers show
Series [v2] drm/bridge: Avoid uninitialized variable warning | expand

Commit Message

Dan Carpenter July 4, 2022, 10:55 a.m. UTC
This code 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.  Initialize the variable to zero to
silence the warning.

Fixes: f32df58acc68 ("drm/bridge: Add the necessary bits to support bus format negotiation")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: initialize the variable instead, this keeps the original error codes.

 drivers/gpu/drm/drm_bridge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Maxime Ripard July 8, 2022, 11:46 a.m. UTC | #1
On Mon, 4 Jul 2022 13:55:40 +0300, Dan Carpenter wrote:
> This code 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.  Initialize the variable to zero to
> silence the warning.
> 
> 

Applied to drm/drm-misc (drm-misc-next).

Thanks!
Maxime
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index e275b4ca344b..d4601201f31d 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -846,8 +846,8 @@  static int select_bus_fmt_recursive(struct drm_bridge *first_bridge,
 				    struct drm_connector_state *conn_state,
 				    u32 out_bus_fmt)
 {
+	unsigned int i, num_in_bus_fmts = 0;
 	struct drm_bridge_state *cur_state;
-	unsigned int num_in_bus_fmts, i;
 	struct drm_bridge *prev_bridge;
 	u32 *in_bus_fmts;
 	int ret;
@@ -968,7 +968,7 @@  drm_atomic_bridge_chain_select_bus_fmts(struct drm_bridge *bridge,
 	struct drm_connector *conn = conn_state->connector;
 	struct drm_encoder *encoder = bridge->encoder;
 	struct drm_bridge_state *last_bridge_state;
-	unsigned int i, num_out_bus_fmts;
+	unsigned int i, num_out_bus_fmts = 0;
 	struct drm_bridge *last_bridge;
 	u32 *out_bus_fmts;
 	int ret = 0;