AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Li, Sun peng (Leo)" <Sunpeng.Li@amd.com>
To: Colin King <colin.king@canonical.com>,
	"Wentland, Harry" <Harry.Wentland@amd.com>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"Koenig, Christian" <Christian.Koenig@amd.com>,
	"Zhou, David(ChunMing)" <David1.Zhou@amd.com>,
	David Airlie <airlied@linux.ie>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Cc: "kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][drm-next] drm/amd/display: fix dereference of pointer fs_params before it is null checked
Date: Tue, 20 Nov 2018 20:08:00 +0000	[thread overview]
Message-ID: <f62f6823-228a-dff9-dad5-45b3fde9c5c2@amd.com> (raw)
In-Reply-To: <20181120171745.13812-1-colin.king@canonical.com>



On 2018-11-20 12:17 p.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently there are several instances of pointer fs_params being
> dereferenced before fs_params is being null checked.  Fix this by
> only dereferencing fs_params after the null check.
> 
> Detected by CoverityScan, CID#1475565 ("Dereference before null check")
> 
> Fixes: e1e8a020c6b8 ("drm/amd/display: Add support for Freesync 2 HDR and Content to Display Mapping")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Reviewed-by: Leo Li <sunpeng.li@amd.com>

Thanks!

> ---
>   .../drm/amd/display/modules/color/color_gamma.c  | 16 +++++++++++-----
>   1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
> index 7480f072c375..bbecbaefb741 100644
> --- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
> +++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
> @@ -813,20 +813,26 @@ static bool build_freesync_hdr(struct pwl_float_data_ex *rgb_regamma,
>   	const struct hw_x_point *coord_x = coordinate_x;
>   	struct fixed31_32 scaledX = dc_fixpt_zero;
>   	struct fixed31_32 scaledX1 = dc_fixpt_zero;
> -	struct fixed31_32 max_display = dc_fixpt_from_int(fs_params->max_display);
> -	struct fixed31_32 min_display = dc_fixpt_from_fraction(fs_params->min_display, 10000);
> -	struct fixed31_32 max_content = dc_fixpt_from_int(fs_params->max_content);
> -	struct fixed31_32 min_content = dc_fixpt_from_fraction(fs_params->min_content, 10000);
> +	struct fixed31_32 max_display;
> +	struct fixed31_32 min_display;
> +	struct fixed31_32 max_content;
> +	struct fixed31_32 min_content;
>   	struct fixed31_32 clip = dc_fixpt_one;
>   	struct fixed31_32 output;
>   	bool use_eetf = false;
>   	bool is_clipped = false;
> -	struct fixed31_32 sdr_white_level = dc_fixpt_from_int(fs_params->sdr_white_level);
> +	struct fixed31_32 sdr_white_level;
>   
>   	if (fs_params == NULL || fs_params->max_content == 0 ||
>   			fs_params->max_display == 0)
>   		return false;
>   
> +	max_display = dc_fixpt_from_int(fs_params->max_display);
> +	min_display = dc_fixpt_from_fraction(fs_params->min_display, 10000);
> +	max_content = dc_fixpt_from_int(fs_params->max_content);
> +	min_content = dc_fixpt_from_fraction(fs_params->min_content, 10000);
> +	sdr_white_level = dc_fixpt_from_int(fs_params->sdr_white_level);
> +
>   	if (fs_params->min_display > 1000) // cap at 0.1 at the bottom
>   		min_display = dc_fixpt_from_fraction(1, 10);
>   	if (fs_params->max_display < 100) // cap at 100 at the top
> 
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2018-11-20 20:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-20 17:17 [PATCH][drm-next] drm/amd/display: fix dereference of pointer fs_params before it is null checked Colin King
2018-11-20 20:08 ` Li, Sun peng (Leo) [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=f62f6823-228a-dff9-dad5-45b3fde9c5c2@amd.com \
    --to=sunpeng.li@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=David1.Zhou@amd.com \
    --cc=Harry.Wentland@amd.com \
    --cc=airlied@linux.ie \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=colin.king@canonical.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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