Re: [PATCH] 2.6.6 memory allocation checks in SliceBlock()

From: Randy.Dunlap (rddunlap_at_osdl.org)
Date: 06/06/04

  • Next message: Pavel Machek: "firewire problems with suspend"
    Date:	Sun, 6 Jun 2004 11:03:33 -0700
    To: Yury Umanets <torque@ukrpost.net>
    
    

    On Sun, 06 Jun 2004 19:23:12 +0300 Yury Umanets wrote:

    | Adds memory allocation checks in SliceBlock()
    |
    | ./linux-2.6.6-modified/drivers/char/drm/sis_ds.c | 4 ++++
    | 1 files changed, 4 insertions(+)
    |
    | Signed-off-by: Yury Umanets <torque@ukrpost.net>
    |
    | diff -rupN ./linux-2.6.6/drivers/char/drm/sis_ds.c
    | ./linux-2.6.6-modified/drivers/char/drm/sis_ds.c
    | --- ./linux-2.6.6/drivers/char/drm/sis_ds.c Mon May 10 05:33:19 2004
    | +++ ./linux-2.6.6-modified/drivers/char/drm/sis_ds.c Wed Jun 2 14:19:22
    | 2004
    | @@ -231,6 +231,8 @@ static TMemBlock* SliceBlock(TMemBlock *
    | if (startofs > p->ofs) {
    | newblock = (TMemBlock*) DRM(calloc)(1, sizeof(TMemBlock),
    | DRM_MEM_DRIVER);
    | + if (!newblock)
    | + return NULL;
    | newblock->ofs = startofs;
    | newblock->size = p->size - (startofs - p->ofs);
    | newblock->free = 1;
    | @@ -244,6 +246,8 @@ static TMemBlock* SliceBlock(TMemBlock *
    | if (size < p->size) {
    | newblock = (TMemBlock*) DRM(calloc)(1, sizeof(TMemBlock),
    | DRM_MEM_DRIVER);
    | + if (!newblock)
    | + return NULL;
    | newblock->ofs = startofs + size;
    | newblock->size = p->size - size;
    | newblock->free = 1;
    |
    | --

    These look like the right thing to do, but one caller of
    SliceBlock() has no error handling:

    mmAllocMem():

            p = SliceBlock(p,startofs,size,0,mask+1);
            p->heap = heap;
            return p;

    However, callers of mmAllocMem() do have failure handling.

    --
    ~Randy
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Pavel Machek: "firewire problems with suspend"

    Relevant Pages

    • Re: [PATCH] 2.6.6 memory allocation checks in SliceBlock()
      ... > | Adds memory allocation checks in SliceBlock() ... > These look like the right thing to do, but one caller of ... callers of mmAllocMem() do have failure handling. ... To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ ...
      (Linux-Kernel)
    • [PATCH] 2.6.6 memory allocation checks in SliceBlock()
      ... Adds memory allocation checks in SliceBlock() ... files changed, 4 insertions(+) ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)