public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: roel kluin <roel.kluin@gmail.com>
Cc: ben-linux@fluff.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sm501: unsigned ptr cannot be negative
Date: Tue, 2 Dec 2008 14:05:37 -0800	[thread overview]
Message-ID: <20081202140537.c76e2b6a.akpm@linux-foundation.org> (raw)
In-Reply-To: <49312C40.3080909@gmail.com>

On Sat, 29 Nov 2008 06:49:20 -0500
roel kluin <roel.kluin@gmail.com> wrote:

> unsigned ptr cannot be negative
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/drivers/video/sm501fb.c b/drivers/video/sm501fb.c
> index f94ae84..dcd9879 100644
> --- a/drivers/video/sm501fb.c
> +++ b/drivers/video/sm501fb.c
> @@ -159,6 +159,9 @@ static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem,
>  		break;
>  
>  	case SM501_MEMF_PANEL:
> +		if (size > inf->fbmem_len)
> +			return -ENOMEM;
> +
>  		ptr = inf->fbmem_len - size;
>  		fbi = inf->fb[HEAD_CRT];
>  
> @@ -172,9 +175,6 @@ static int sm501_alloc_mem(struct sm501fb_info *inf, struct sm501_mem *mem,
>  		if (fbi && ptr < fbi->fix.smem_len)
>  			return -ENOMEM;
>  
> -		if (ptr < 0)
> -			return -ENOMEM;
> -
>  		break;
>  
>  	case SM501_MEMF_CRT:

Looks OK.

Also this:

	if (ptr > 0)
		ptr &= ~(PAGE_SIZE - 1);

could just be

	ptr = PAGE_ALIGN(ptr);					

      reply	other threads:[~2008-12-02 22:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-29 11:49 [PATCH] sm501: unsigned ptr cannot be negative roel kluin
2008-12-02 22:05 ` Andrew Morton [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=20081202140537.c76e2b6a.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ben-linux@fluff.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roel.kluin@gmail.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