Linux Framebuffer Layer development
 help / color / mirror / Atom feed
From: Jingoo Han <jg1.han@samsung.com>
To: 'Olof Johansson' <olof@lixom.net>
Cc: 'Florian Tobias Schandinat' <FlorianSchandinat@gmx.de>,
	linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: RE: [PATCH] video: exynos: fix build warning and bad pointer deref in dp driver
Date: Mon, 09 Apr 2012 08:46:56 +0000	[thread overview]
Message-ID: <002301cd162d$51bd6b00$f5384100$%han@samsung.com> (raw)
In-Reply-To: <1333944982-15859-1-git-send-email-olof@lixom.net>

> -----Original Message-----
> From: Olof Johansson [mailto:olof@lixom.net]
> Sent: Monday, April 09, 2012 1:16 PM
> 
> I'm not 100% sure if the fix for 'adjust_request' is correct, since
> it's uncertain what the original intent was. But it's so clearly an
> uninitialized pointer dereference that my resolution seems to make sense.
> 
> drivers/video/exynos/exynos_dp_core.c: In function 'exynos_dp_set_link_train':
> drivers/video/exynos/exynos_dp_core.c:521:21: warning: 'adjust_request' may be used uninitialized in
> this function [-Wuninitialized]
> drivers/video/exynos/exynos_dp_core.c:481:6: note: 'adjust_request' was declared here
> drivers/video/exynos/exynos_dp_core.c:529:18: warning: 'reg' may be used uninitialized in this function
> [-Wuninitialized]
> drivers/video/exynos/exynos_dp_core.c:395:6: note: 'reg' was declared here
> 
> Signed-off-by: Olof Johansson <olof@lixom.net>
> ---
>  drivers/video/exynos/exynos_dp_core.c |   23 +++++++++--------------
>  1 file changed, 9 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
> index 2a4481c..8973e18 100644
> --- a/drivers/video/exynos/exynos_dp_core.c
> +++ b/drivers/video/exynos/exynos_dp_core.c
> @@ -392,24 +392,19 @@ static unsigned int exynos_dp_get_lane_link_training(
>  				struct exynos_dp_device *dp,
>  				int lane)
>  {
> -	u32 reg;
> -
>  	switch (lane) {
>  	case 0:
> -		reg = exynos_dp_get_lane0_link_training(dp);
> -		break;
> +		return exynos_dp_get_lane0_link_training(dp);
>  	case 1:
> -		reg = exynos_dp_get_lane1_link_training(dp);
> -		break;
> +		return exynos_dp_get_lane1_link_training(dp);
>  	case 2:
> -		reg = exynos_dp_get_lane2_link_training(dp);
> -		break;
> +		return exynos_dp_get_lane2_link_training(dp);
>  	case 3:
> -		reg = exynos_dp_get_lane3_link_training(dp);
> -		break;
> +		return exynos_dp_get_lane3_link_training(dp);
>  	}

I don't like multi return.

> 
> -	return reg;
> +	WARN_ON(1);
> +	return 0;
>  }
> 
>  static void exynos_dp_reduce_link_rate(struct exynos_dp_device *dp)
> @@ -489,13 +484,13 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
>  				6, link_status);
>  	lane_count = dp->link_train.lane_count;
> 
> +	adjust_request = link_status + (DPCD_ADDR_ADJUST_REQUEST_LANE0_1
> +					- DPCD_ADDR_LANE0_1_STATUS);
> +

It makes the problem. adjust_request will be different.

OK, I understand what you want to do.
I will send the version 2 patch which is simpler.

Thank you for sending the patch.

>  	if (exynos_dp_clock_recovery_ok(link_status, lane_count) = 0) {
>  		/* set training pattern 2 for EQ */
>  		exynos_dp_set_training_pattern(dp, TRAINING_PTN2);
> 
> -		adjust_request = link_status + (DPCD_ADDR_ADJUST_REQUEST_LANE0_1
> -						- DPCD_ADDR_LANE0_1_STATUS);
> -
>  		exynos_dp_get_adjust_train(dp, adjust_request);
> 
>  		buf[0] = DPCD_SCRAMBLING_DISABLED |
> --
> 1.7.9.2.359.gebfc2


  reply	other threads:[~2012-04-09  8:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-09  4:16 [PATCH] video: exynos: fix build warning and bad pointer deref in dp driver Olof Johansson
2012-04-09  8:46 ` Jingoo Han [this message]
2012-04-09 14:05   ` Olof Johansson
2012-04-09  9:25 ` Jingoo Han
2012-04-09 14:07   ` Olof Johansson

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='002301cd162d$51bd6b00$f5384100$%han@samsung.com' \
    --to=jg1.han@samsung.com \
    --cc=FlorianSchandinat@gmx.de \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olof@lixom.net \
    /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