[PATCH] drivers/char/pc_keyb.c: checking resource allocation

From: Arnaldo Carvalho de Melo (acme@conectiva.com.br)
Date: Mon Aug 14 2000 - 11:45:10 EST


Linus,

     Please take a look and consider applying.

                        - Arnaldo

--- linux-2.4.0-test7-pre3/drivers/char/pc_keyb.c Thu Jul 13 01:58:42 2000
+++ linux-2.4.0-test7-pre3.acme/drivers/char/pc_keyb.c Mon Aug 14 13:43:20 2000
@@ -13,6 +13,9 @@
  * Code fixes to handle mouse ACKs properly.
  * C. Scott Ananian <cananian@alumni.princeton.edu> 1999-01-29.
  *
+ * Check resource allocation in psaux_init
+ * Arnaldo Carvalho de Melo <acme@conectiva.com.br> 2000-08-14
+ *
  */
 
 #include <linux/config.h>
@@ -1007,11 +1010,23 @@
 
 static int __init psaux_init(void)
 {
+ int ret;
+
         if (!detect_auxiliary_port())
                 return -EIO;
 
- misc_register(&psaux_mouse);
         queue = (struct aux_queue *) kmalloc(sizeof(*queue), GFP_KERNEL);
+
+ if (!queue)
+ return -ENOMEM;
+
+ ret = misc_register(&psaux_mouse);
+
+ if (ret)
+ kfree(queue);
+ return ret;
+ }
+
         memset(queue, 0, sizeof(*queue));
         queue->head = queue->tail = 0;
         init_waitqueue_head(&queue->proc_list);

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



This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 21:00:33 EST