On Sat, 19 July 2008 "nagaraj s k" <[EMAIL PROTECTED]> wrote:
> Hi ALL,
> 
> Sorry about repetitive mails, i forgot to add the main mail list,
> getting used to the procedure to send patches.
> 
> This is my second submission (looks like first mail lost in the
> malling list 10 days earlier). I did my best to follow the guidelines
> put forth for newbies. Please feel free for any comments and
> suggestions.Currently working on 2.6.26.I have applied this patch to
> my existing kernel and all looks fine, also checked for white space.
> 
> Fixed few simple compilation errors like logical assignment
> operators,white space between pointer variables
>  and cleaned up to few warnings.
> 
> Signed-off-by: Nagaraj SK <[EMAIL PROTECTED]>
>  ___
> 
> --- linux-2.6.26/drivers/char/drm/drm_memory.c    2008-07-14
> 03:21:29.000000000 +0530
> +++ linux-staging/drivers/char/drm/drm_memory.c    2008-07-20
> 00:22:51.000000000 +0530
> @@ -69,7 +69,7 @@ void *drm_realloc(void *oldpt, size_t ol
>  {
>      void *pt;
> 
> -    if (!(pt = kmalloc(size, GFP_KERNEL)))
> +    if (!(pt == kmalloc(size, GFP_KERNEL)))
>          return NULL;
>      if (oldpt && oldsize) {
>          memcpy(pt, oldpt, oldsize);

The original code is correct, your change causes memory leak and
drm_realloc() to return NULL in nearly all cases (and Oops if
kmalloc fails and uninitialized pt happens to be NULL).

The original code checks if kmalloc worked and returns NULL if not.
Note the () around the assignment, the original code block means:

void *pt;

pt = kmalloc(size, GFP_KERNEL);
if (!pt)
        return NULL;

Bruno

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to