* [PATCH] 2.6.6 memory allocation checks in SliceBlock()
@ 2004-06-06 16:23 Yury Umanets
2004-06-06 18:03 ` Randy.Dunlap
0 siblings, 1 reply; 3+ messages in thread
From: Yury Umanets @ 2004-06-06 16:23 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
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;
--
umka
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] 2.6.6 memory allocation checks in SliceBlock() 2004-06-06 16:23 [PATCH] 2.6.6 memory allocation checks in SliceBlock() Yury Umanets @ 2004-06-06 18:03 ` Randy.Dunlap 2004-06-07 15:54 ` Yury Umanets 0 siblings, 1 reply; 3+ messages in thread From: Randy.Dunlap @ 2004-06-06 18:03 UTC (permalink / raw) To: Yury Umanets; +Cc: akpm, linux-kernel 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] 2.6.6 memory allocation checks in SliceBlock() 2004-06-06 18:03 ` Randy.Dunlap @ 2004-06-07 15:54 ` Yury Umanets 0 siblings, 0 replies; 3+ messages in thread From: Yury Umanets @ 2004-06-07 15:54 UTC (permalink / raw) To: Randy.Dunlap; +Cc: akpm, linux-kernel On Sun, 2004-06-06 at 21:03, Randy.Dunlap wrote: > 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. Hello Randy, This is fixed version: ./linux-2.6.6-modified/drivers/char/drm/sis_ds.c | 6 ++++++ 1 files changed, 6 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 Mon Jun 7 18:41:41 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; @@ -285,6 +289,8 @@ PMemBlock mmAllocMem( memHeap_t *heap, i if (p == NULL) return NULL; p = SliceBlock(p,startofs,size,0,mask+1); + if (!p) + return NULL; p->heap = heap; return p; } -- umka ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-06-07 15:55 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2004-06-06 16:23 [PATCH] 2.6.6 memory allocation checks in SliceBlock() Yury Umanets 2004-06-06 18:03 ` Randy.Dunlap 2004-06-07 15:54 ` Yury Umanets
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox