mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
drm/amd/display: drop unnecessary NULL checks in debugfs
[ Upstream commit f8e12e770e ]
pipe_ctx pointer cannot be NULL when getting the address of
an element of the pipe_ctx array. Moreover, the MAX_PIPES is
defined as 6, so pipe_ctx is not NULL after the loop either.
Detected using the static analysis tool - Svace.
Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Stable-dep-of: 892b41b16f61 ("drm/amd/display: Fix incorrect DSC instance for MST")
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
b6621895b4
commit
ed82dc58c7
@@ -1369,16 +1369,11 @@ static ssize_t dp_dsc_clock_en_read(struct file *f, char __user *buf,
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx) {
|
||||
kfree(rd_buf);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
dsc = pipe_ctx->stream_res.dsc;
|
||||
if (dsc)
|
||||
dsc->funcs->dsc_read_state(dsc, &dsc_state);
|
||||
@@ -1475,12 +1470,12 @@ static ssize_t dp_dsc_clock_en_write(struct file *f, const char __user *buf,
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx || !pipe_ctx->stream)
|
||||
if (!pipe_ctx->stream)
|
||||
goto done;
|
||||
|
||||
// Get CRTC state
|
||||
@@ -1560,16 +1555,11 @@ static ssize_t dp_dsc_slice_width_read(struct file *f, char __user *buf,
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx) {
|
||||
kfree(rd_buf);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
dsc = pipe_ctx->stream_res.dsc;
|
||||
if (dsc)
|
||||
dsc->funcs->dsc_read_state(dsc, &dsc_state);
|
||||
@@ -1664,12 +1654,12 @@ static ssize_t dp_dsc_slice_width_write(struct file *f, const char __user *buf,
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx || !pipe_ctx->stream)
|
||||
if (!pipe_ctx->stream)
|
||||
goto done;
|
||||
|
||||
// Safely get CRTC state
|
||||
@@ -1749,16 +1739,11 @@ static ssize_t dp_dsc_slice_height_read(struct file *f, char __user *buf,
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx) {
|
||||
kfree(rd_buf);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
dsc = pipe_ctx->stream_res.dsc;
|
||||
if (dsc)
|
||||
dsc->funcs->dsc_read_state(dsc, &dsc_state);
|
||||
@@ -1853,12 +1838,12 @@ static ssize_t dp_dsc_slice_height_write(struct file *f, const char __user *buf,
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx || !pipe_ctx->stream)
|
||||
if (!pipe_ctx->stream)
|
||||
goto done;
|
||||
|
||||
// Get CRTC state
|
||||
@@ -1934,16 +1919,11 @@ static ssize_t dp_dsc_bits_per_pixel_read(struct file *f, char __user *buf,
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx) {
|
||||
kfree(rd_buf);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
dsc = pipe_ctx->stream_res.dsc;
|
||||
if (dsc)
|
||||
dsc->funcs->dsc_read_state(dsc, &dsc_state);
|
||||
@@ -2035,12 +2015,12 @@ static ssize_t dp_dsc_bits_per_pixel_write(struct file *f, const char __user *bu
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx || !pipe_ctx->stream)
|
||||
if (!pipe_ctx->stream)
|
||||
goto done;
|
||||
|
||||
// Get CRTC state
|
||||
@@ -2114,16 +2094,11 @@ static ssize_t dp_dsc_pic_width_read(struct file *f, char __user *buf,
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx) {
|
||||
kfree(rd_buf);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
dsc = pipe_ctx->stream_res.dsc;
|
||||
if (dsc)
|
||||
dsc->funcs->dsc_read_state(dsc, &dsc_state);
|
||||
@@ -2175,16 +2150,11 @@ static ssize_t dp_dsc_pic_height_read(struct file *f, char __user *buf,
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx) {
|
||||
kfree(rd_buf);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
dsc = pipe_ctx->stream_res.dsc;
|
||||
if (dsc)
|
||||
dsc->funcs->dsc_read_state(dsc, &dsc_state);
|
||||
@@ -2251,16 +2221,11 @@ static ssize_t dp_dsc_chunk_size_read(struct file *f, char __user *buf,
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx) {
|
||||
kfree(rd_buf);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
dsc = pipe_ctx->stream_res.dsc;
|
||||
if (dsc)
|
||||
dsc->funcs->dsc_read_state(dsc, &dsc_state);
|
||||
@@ -2327,16 +2292,11 @@ static ssize_t dp_dsc_slice_bpg_offset_read(struct file *f, char __user *buf,
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
pipe_ctx = &aconnector->dc_link->dc->current_state->res_ctx.pipe_ctx[i];
|
||||
if (pipe_ctx && pipe_ctx->stream &&
|
||||
if (pipe_ctx->stream &&
|
||||
pipe_ctx->stream->link == aconnector->dc_link)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pipe_ctx) {
|
||||
kfree(rd_buf);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
dsc = pipe_ctx->stream_res.dsc;
|
||||
if (dsc)
|
||||
dsc->funcs->dsc_read_state(dsc, &dsc_state);
|
||||
|
||||
Reference in New Issue
Block a user