[PATCH][2.4.20-ac] check kmalloc return in sis_ds.c

From: Zwane Mwaikambo (zwane@mwaikambo.name)
Date: Sun Sep 01 2002 - 09:12:39 EST


Hi Alan,
        Diffed against 2.5.33 but applies clean to 2.4.20-pre4-ac1, i
presumed there would be no point in sending this for 2.5 seeing as that
isn't as current as whats in your tree.

        Zwane

Index: linux-2.5.33/drivers/char/drm/sis_ds.c
===================================================================
RCS file: /build/cvsroot/linux-2.5.33/drivers/char/drm/sis_ds.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 sis_ds.c
--- linux-2.5.33/drivers/char/drm/sis_ds.c 31 Aug 2002 22:30:31 -0000 1.1.1.1
+++ linux-2.5.33/drivers/char/drm/sis_ds.c 1 Sep 2002 11:25:53 -0000
@@ -50,15 +50,16 @@
   set_t *set;
 
   set = (set_t *)MALLOC(sizeof(set_t));
- for(i = 0; i < SET_SIZE; i++){
- set->list[i].free_next = i+1;
- set->list[i].alloc_next = -1;
- }
- set->list[SET_SIZE-1].free_next = -1;
- set->free = 0;
- set->alloc = -1;
- set->trace = -1;
-
+ if (set) {
+ for(i = 0; i < SET_SIZE; i++){
+ set->list[i].free_next = i+1;
+ set->list[i].alloc_next = -1;
+ }
+ set->list[SET_SIZE-1].free_next = -1;
+ set->free = 0;
+ set->alloc = -1;
+ set->trace = -1;
+ }
   return set;
 }
 
@@ -172,7 +173,8 @@
 {
   void *addr;
   addr = kmalloc(nmemb*size, GFP_KERNEL);
- memset(addr, 0, nmemb*size);
+ if (addr)
+ memset(addr, 0, nmemb*size);
   return addr;
 }
 #define free(n) kfree(n)

-- 
function.linuxpower.ca

- 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/



This archive was generated by hypermail 2b29 : Sat Sep 07 2002 - 22:00:14 EST