[PATCH] drivers/char/qpmouse.c resource allocation fixes

From: Arnaldo Carvalho de Melo (acme@conectiva.com.br)
Date: Mon Aug 14 2000 - 15:40:48 EST


Hi,

    Please take a look and consider applying.

                        - Arnaldo

--- linux-2.4.0-test7-pre3/drivers/char/qpmouse.c Thu Jul 13 01:58:42 2000
+++ linux-2.4.0-test7-pre3.acme/drivers/char/qpmouse.c Mon Aug 14 17:35:36 2000
@@ -21,6 +21,9 @@
  * Rearranged SIGIO support to use code from tty_io. 9Sept95 ctm@ardi.com
  *
  * Modularised 8-Sep-95 Philip Blundell <pjb27@cam.ac.uk>
+ *
+ * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 08/14/2000
+ * - check resource allocation in qpmouse_init
  */
 
 #include <linux/module.h>
@@ -339,14 +342,27 @@
 
 int __init qpmouse_init(void)
 {
+ int ret;
+
         if (!probe_qp())
                 return -EIO;
 
+ queue = (struct qp_queue *) kmalloc(sizeof(*queue), GFP_KERNEL);
+
+ if (!queue)
+ return -ENOMEM;
+
+ ret = misc_register(&qp_mouse);
+
+ if (ret) {
+ kfree(queue);
+ return ret;
+ }
+
         printk(KERN_INFO "82C710 type pointing device detected -- driver installed.\n");
 /* printk("82C710 address = %x (should be 0x310)\n", qp_data); */
         qp_present = 1;
- misc_register(&qp_mouse);
- queue = (struct qp_queue *) kmalloc(sizeof(*queue), GFP_KERNEL);
+
         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:34 EST