mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hamza Mahfooz <hamza.mahfooz@amd.com>
To: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Cc: dri-devel@lists.freedesktop.org,
	"Josip Pavic" <Josip.Pavic@amd.com>,
	amd-gfx@lists.freedesktop.org, error27@gmail.com,
	"Leo Li" <sunpeng.li@amd.com>,
	kernel-janitors@vger.kernel.org,
	"Qingqing Zhuo" <qingqing.zhuo@amd.com>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>,
	"Rodrigo Siqueira" <Rodrigo.Siqueira@amd.com>,
	linux-kernel@vger.kernel.org,
	"Nicholas Kazlauskas" <Nicholas.Kazlauskas@amd.com>,
	"Max Tseng" <Max.Tseng@amd.com>, "Alvin Lee" <Alvin.Lee2@amd.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"David Airlie" <airlied@gmail.com>, "Jun Lei" <Jun.Lei@amd.com>,
	"Harry Wentland" <harry.wentland@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Eric Yang" <Eric.Yang2@amd.com>
Subject: Re: [PATCH next] drm/amd/display: Fix possible NULL dereference in dc_dmub_srv_cmd_run_list()
Date: Wed, 26 Apr 2023 16:59:46 -0400	[thread overview]
Message-ID: <57a7ccb9-ff94-22ad-9b66-235b42228c7f@amd.com> (raw)
In-Reply-To: <20230426192413.143971-1-harshit.m.mogalapalli@oracle.com>

On 4/26/23 15:24, Harshit Mogalapalli wrote:
> We have a NULL check for 'dc_dmub_srv' in dc_dmub_srv_cmd_run_list()
> but we are dereferencing it before checking.
> 
> Fix this moving the dereference next to NULL check.
> 
> This issue is found with Smatch(static analysis tool).
> 
> Fixes: e97cc04fe0fb ("drm/amd/display: refactor dmub commands into single function")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>

Applied, thanks!

> ---
> Only compile tested.
> ---
>   drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
> index d15ec32243e2..62d3473c32bc 100644
> --- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
> +++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
> @@ -125,7 +125,7 @@ bool dc_dmub_srv_cmd_run(struct dc_dmub_srv *dc_dmub_srv, union dmub_rb_cmd *cmd
>   
>   bool dc_dmub_srv_cmd_run_list(struct dc_dmub_srv *dc_dmub_srv, unsigned int count, union dmub_rb_cmd *cmd_list, enum dm_dmub_wait_type wait_type)
>   {
> -	struct dc_context *dc_ctx = dc_dmub_srv->ctx;
> +	struct dc_context *dc_ctx;
>   	struct dmub_srv *dmub;
>   	enum dmub_status status;
>   	int i;
> @@ -133,6 +133,7 @@ bool dc_dmub_srv_cmd_run_list(struct dc_dmub_srv *dc_dmub_srv, unsigned int coun
>   	if (!dc_dmub_srv || !dc_dmub_srv->dmub)
>   		return false;
>   
> +	dc_ctx = dc_dmub_srv->ctx;
>   	dmub = dc_dmub_srv->dmub;
>   
>   	for (i = 0 ; i < count; i++) {
-- 
Hamza


      reply	other threads:[~2023-04-26 20:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-26 19:24 Harshit Mogalapalli
2023-04-26 20:59 ` Hamza Mahfooz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57a7ccb9-ff94-22ad-9b66-235b42228c7f@amd.com \
    --to=hamza.mahfooz@amd.com \
    --cc=Alvin.Lee2@amd.com \
    --cc=Eric.Yang2@amd.com \
    --cc=Josip.Pavic@amd.com \
    --cc=Jun.Lei@amd.com \
    --cc=Max.Tseng@amd.com \
    --cc=Nicholas.Kazlauskas@amd.com \
    --cc=Rodrigo.Siqueira@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=error27@gmail.com \
    --cc=harry.wentland@amd.com \
    --cc=harshit.m.mogalapalli@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qingqing.zhuo@amd.com \
    --cc=sunpeng.li@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®