* [PATCH] drm/amd/display: Fix pointer dereferenced before checking
@ 2022-04-07 5:52 Haowen Bai
2022-04-07 14:17 ` Harry Wentland
0 siblings, 1 reply; 5+ messages in thread
From: Haowen Bai @ 2022-04-07 5:52 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, Pan, Xinhui, David Airlie, Daniel Vetter
Cc: Haowen Bai, dri-devel, amd-gfx, linux-kernel
The pointer dc is dereferencing pointer plane_state before plane_state
is being null checked. Fix this by assigning plane_state->ctx->dc to
dc only if plane_state is not NULL, otherwise just NULL.
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
index 50820e79d3c4..ee22f4422d26 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
@@ -3211,7 +3211,7 @@ void dcn10_update_pending_status(struct pipe_ctx *pipe_ctx)
struct dc_plane_state *plane_state = pipe_ctx->plane_state;
struct timing_generator *tg = pipe_ctx->stream_res.tg;
bool flip_pending;
- struct dc *dc = plane_state->ctx->dc;
+ struct dc *dc = plane_state ? plane_state->ctx->dc : NULL;
if (plane_state == NULL)
return;
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/amd/display: Fix pointer dereferenced before checking
2022-04-07 5:52 [PATCH] drm/amd/display: Fix pointer dereferenced before checking Haowen Bai
@ 2022-04-07 14:17 ` Harry Wentland
0 siblings, 0 replies; 5+ messages in thread
From: Harry Wentland @ 2022-04-07 14:17 UTC (permalink / raw)
To: Haowen Bai, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, Pan, Xinhui, David Airlie, Daniel Vetter
Cc: amd-gfx, dri-devel, linux-kernel
On 2022-04-07 01:52, Haowen Bai wrote:
> The pointer dc is dereferencing pointer plane_state before plane_state
> is being null checked. Fix this by assigning plane_state->ctx->dc to
> dc only if plane_state is not NULL, otherwise just NULL.
>
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
> drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
> index 50820e79d3c4..ee22f4422d26 100644
> --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
> +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
> @@ -3211,7 +3211,7 @@ void dcn10_update_pending_status(struct pipe_ctx *pipe_ctx)
> struct dc_plane_state *plane_state = pipe_ctx->plane_state;
> struct timing_generator *tg = pipe_ctx->stream_res.tg;
> bool flip_pending;
> - struct dc *dc = plane_state->ctx->dc;
This has worked for years now, meaning plane_state is never
NULL here. It might be better to drop the NULL check below.
Harry
> + struct dc *dc = plane_state ? plane_state->ctx->dc : NULL;
>
> if (plane_state == NULL)
> return;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/amd/display: Fix pointer dereferenced before checking
2022-03-24 9:46 Haowen Bai
@ 2022-03-25 19:57 ` Alex Deucher
0 siblings, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2022-03-25 19:57 UTC (permalink / raw)
To: Haowen Bai
Cc: Leo (Sunpeng) Li, xinhui pan, Siqueira, Rodrigo, LKML,
Maling list - DRI developers, Dave Airlie, amd-gfx list, Deucher,
Alexander, Christian Koenig
Applied both patches. Thanks!
Alex
On Thu, Mar 24, 2022 at 9:46 AM Haowen Bai <baihaowen@meizu.com> wrote:
>
> The value actual_pix_clk_100Hz is dereferencing pointer pix_clk_params
> before pix_clk_params is being null checked. Fix this by assigning
> pix_clk_params->requested_pix_clk_100hz to actual_pix_clk_100Hz only if
> pix_clk_params is not NULL, otherwise just NULL.
>
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
> drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
> index 2c7eb98..4db45bb 100644
> --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
> +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
> @@ -1162,7 +1162,7 @@ static uint32_t dcn3_get_pix_clk_dividers(
> struct pixel_clk_params *pix_clk_params,
> struct pll_settings *pll_settings)
> {
> - unsigned long long actual_pix_clk_100Hz = pix_clk_params->requested_pix_clk_100hz;
> + unsigned long long actual_pix_clk_100Hz = pix_clk_params ? pix_clk_params->requested_pix_clk_100hz : 0;
> struct dce110_clk_src *clk_src;
>
> clk_src = TO_DCE110_CLK_SRC(cs);
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] drm/amd/display: Fix pointer dereferenced before checking
@ 2022-03-24 9:46 Haowen Bai
2022-03-25 19:57 ` Alex Deucher
0 siblings, 1 reply; 5+ messages in thread
From: Haowen Bai @ 2022-03-24 9:46 UTC (permalink / raw)
To: harry.wentland, sunpeng.li, Rodrigo.Siqueira, alexander.deucher,
christian.koenig, Xinhui.Pan, airlied, daniel
Cc: Haowen Bai, dri-devel, amd-gfx, linux-kernel
The value actual_pix_clk_100Hz is dereferencing pointer pix_clk_params
before pix_clk_params is being null checked. Fix this by assigning
pix_clk_params->requested_pix_clk_100hz to actual_pix_clk_100Hz only if
pix_clk_params is not NULL, otherwise just NULL.
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
index 2c7eb98..4db45bb 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
@@ -1162,7 +1162,7 @@ static uint32_t dcn3_get_pix_clk_dividers(
struct pixel_clk_params *pix_clk_params,
struct pll_settings *pll_settings)
{
- unsigned long long actual_pix_clk_100Hz = pix_clk_params->requested_pix_clk_100hz;
+ unsigned long long actual_pix_clk_100Hz = pix_clk_params ? pix_clk_params->requested_pix_clk_100hz : 0;
struct dce110_clk_src *clk_src;
clk_src = TO_DCE110_CLK_SRC(cs);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] drm/amd/display: Fix pointer dereferenced before checking
@ 2022-03-24 9:27 Haowen Bai
0 siblings, 0 replies; 5+ messages in thread
From: Haowen Bai @ 2022-03-24 9:27 UTC (permalink / raw)
To: harry.wentland, sunpeng.li, Rodrigo.Siqueira, alexander.deucher,
christian.koenig, Xinhui.Pan, airlied, daniel,
nicholas.kazlauskas, lyude, Jerry.Zuo
Cc: Haowen Bai, dri-devel, amd-gfx, linux-kernel
The pointer edid_buf is dereferencing pointer edid before edid is being
null checked. Fix this by assigning edid->raw_edid to edid_buf only if
edid is not NULL, otherwise just NULL.
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index 29f07c2..360401d 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -89,7 +89,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
{
struct amdgpu_dm_connector *aconnector = link->priv;
struct drm_connector *connector = &aconnector->base;
- struct edid *edid_buf = (struct edid *) edid->raw_edid;
+ struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
struct cea_sad *sads;
int sad_count = -1;
int sadb_count = -1;
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-08 7:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 5:52 [PATCH] drm/amd/display: Fix pointer dereferenced before checking Haowen Bai
2022-04-07 14:17 ` Harry Wentland
-- strict thread matches above, loose matches on Subject: below --
2022-03-24 9:46 Haowen Bai
2022-03-25 19:57 ` Alex Deucher
2022-03-24 9:27 Haowen Bai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).