Skip to contentSkip to conversation

drm/amd/display: Remove redundant assignment to variable dc

PATCH Applied Yi Yang 3 participants 3 messages Dec 16, 2022 – Jan 6, 2023

Subsystems (3)
lore
Share & tools
lore

Yi Yang

author
#0 lore raw

PATCH 1/1 drm/amd/display: Remove redundant assignment to variable dc

Smatch report warning as follows:

Line 53679: drivers/gpu/drm/amd/display/dc/core/dc_stream.c:402 dc_stream_set_cursor_position() warn: variable dereferenced before check 'stream'

The value of 'dc' has been assigned after check whether 'stream' is NULL. Fix it by remove redundant assignment.

---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_stream.c +1 -1
index 20e534f73513..78d31bb875d1 100644
@@ -408,7 +408,7 @@ bool dc_stream_set_cursor_position(
 	struct dc_stream_state *stream,
 	const struct dc_cursor_position *position)
 {
-	struct dc  *dc = stream->ctx->dc;
+	struct dc *dc;
 	bool reset_idle_optimizations = false;
 
 	if (NULL == stream) {
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Yi Yang

Smatch report warning as follows:

Line 53679: drivers/gpu/drm/amd/display/dc/core/dc_stream.c:402 dc_stream_set_cursor_position() warn: variable dereferenced before check 'stream'

The value of 'dc' has been assigned after check whether 'stream' is NULL. Fix it by remove redundant assignment.

If this didn't blow up until now we might not even need the NULL check below, but either way this is correct and

Harry

Quoted 17 lines
---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_stream.c +1 -1
index 20e534f73513..78d31bb875d1 100644
@@ -408,7 +408,7 @@ bool dc_stream_set_cursor_position(
 	struct dc_stream_state *stream,
 	const struct dc_cursor_position *position)
 {
-	struct dc  *dc = stream->ctx->dc;
+	struct dc *dc;
 	bool reset_idle_optimizations = false;
 
 	if (NULL == stream) {
Applied
#2 lore raw

Applied. Thanks!

Alex

Quoted 38 lines · Harry Wentland
Quoted 10 lines · Yi Yang

Smatch report warning as follows:

Line 53679: drivers/gpu/drm/amd/display/dc/core/dc_stream.c:402 dc_stream_set_cursor_position() warn: variable dereferenced before check 'stream'

The value of 'dc' has been assigned after check whether 'stream' is NULL. Fix it by remove redundant assignment.

If this didn't blow up until now we might not even need the NULL check below, but either way this is correct and

Harry

Quoted 17 lines
---
 drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_stream.c +1 -1
index 20e534f73513..78d31bb875d1 100644
@@ -408,7 +408,7 @@ bool dc_stream_set_cursor_position(
      struct dc_stream_state *stream,
      const struct dc_cursor_position *position)
 {
-     struct dc  *dc = stream->ctx->dc;
+     struct dc *dc;
      bool reset_idle_optimizations = false;
 
      if (NULL == stream) {