PATCH: kmallocs with mixed up arguments

From: Kevin Buhr (buhr@stat.wisc.edu)
Date: Fri Jul 21 2000 - 00:53:54 EST


Linus:

In 2.4.0-test4, there are several kmalloc calls with the arguments
interchanged. I got bitten by the one in "daisy.c", so I did:

        egrep 'kmalloc *\( *GFP'

to catch the others.

None seem fixed in test5-pre3, so I've enclosed a patch (against
test4) for all the ones I found.

Kevin <buhr@stat.wisc.edu>

                        * * *

diff -ru linux-2.4.0-test4/arch/sparc64/kernel/ioctl32.c linux-2.4.0-test4-local/arch/sparc64/kernel/ioctl32.c
--- linux-2.4.0-test4/arch/sparc64/kernel/ioctl32.c Fri Jul 21 00:24:18 2000
+++ linux-2.4.0-test4-local/arch/sparc64/kernel/ioctl32.c Fri Jul 21 00:40:33 2000
@@ -1085,7 +1085,7 @@
                 {
                         struct floppy_struct *f;
 
- f = karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_struct));
+ f = karg = kmalloc(sizeof(struct floppy_struct), GFP_KERNEL);
                         if (!karg)
                                 return -ENOMEM;
                         if (cmd == FDGETPRM32)
@@ -1111,7 +1111,7 @@
                 {
                         struct floppy_drive_params *f;
 
- f = karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_drive_params));
+ f = karg = kmalloc(sizeof(struct floppy_drive_params), GFP_KERNEL);
                         if (!karg)
                                 return -ENOMEM;
                         if (cmd == FDGETDRVPRM32)
@@ -1143,17 +1143,17 @@
                 }
                 case FDGETDRVSTAT32:
                 case FDPOLLDRVSTAT32:
- karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_drive_struct));
+ karg = kmalloc(sizeof(struct floppy_drive_struct), GFP_KERNEL);
                         if (!karg)
                                 return -ENOMEM;
                         break;
                 case FDGETFDCSTAT32:
- karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_fdc_state));
+ karg = kmalloc(sizeof(struct floppy_fdc_state), GFP_KERNEL);
                         if (!karg)
                                 return -ENOMEM;
                         break;
                 case FDWERRORGET32:
- karg = kmalloc(GFP_KERNEL, sizeof(struct floppy_write_errors));
+ karg = kmalloc(sizeof(struct floppy_write_errors), GFP_KERNEL);
                         if (!karg)
                                 return -ENOMEM;
                         break;
diff -ru linux-2.4.0-test4/drivers/ide/ide-tape.c linux-2.4.0-test4-local/drivers/ide/ide-tape.c
--- linux-2.4.0-test4/drivers/ide/ide-tape.c Fri Jul 21 00:26:15 2000
+++ linux-2.4.0-test4-local/drivers/ide/ide-tape.c Fri Jul 21 00:41:29 2000
@@ -1539,7 +1539,7 @@
  
 /**************************************************************
  * *
- * This should get fixed to use kmalloc(GFP_ATOMIC, ..) *
+ * This should get fixed to use kmalloc(.., GFP_ATOMIC) *
  * followed later on by kfree(). -ml *
  * *
  **************************************************************/
diff -ru linux-2.4.0-test4/drivers/parport/daisy.c linux-2.4.0-test4-local/drivers/parport/daisy.c
--- linux-2.4.0-test4/drivers/parport/daisy.c Fri Jul 21 00:25:32 2000
+++ linux-2.4.0-test4-local/drivers/parport/daisy.c Fri Jul 21 00:29:38 2000
@@ -51,7 +51,7 @@
 static void add_dev (int devnum, struct parport *port, int daisy)
 {
         struct daisydev *newdev;
- newdev = kmalloc (GFP_KERNEL, sizeof (struct daisydev));
+ newdev = kmalloc (sizeof (struct daisydev), GFP_KERNEL);
         if (newdev) {
                 newdev->port = port;
                 newdev->daisy = daisy;
diff -ru linux-2.4.0-test4/drivers/s390/misc/chandev.c linux-2.4.0-test4-local/drivers/s390/misc/chandev.c
--- linux-2.4.0-test4/drivers/s390/misc/chandev.c Fri Jul 21 00:23:01 2000
+++ linux-2.4.0-test4-local/drivers/s390/misc/chandev.c Fri Jul 21 00:41:29 2000
@@ -31,7 +31,7 @@
 
 static void *chandev_alloc_listmember(list **listhead,size_t size)
 {
- void *newmember=kmalloc(GFP_KERNEL,size);
+ void *newmember=kmalloc(size, GFP_KERNEL);
         if(newmember)
                 add_to_list(listhead,newmember);
         return(newmember);
diff -ru linux-2.4.0-test4/net/econet/af_econet.c linux-2.4.0-test4-local/net/econet/af_econet.c
--- linux-2.4.0-test4/net/econet/af_econet.c Mon Apr 24 15:43:04 2000
+++ linux-2.4.0-test4-local/net/econet/af_econet.c Fri Jul 21 00:37:55 2000
@@ -594,7 +594,7 @@
                 if (edev == NULL)
                 {
                         /* Magic up a new one. */
- edev = kmalloc(GFP_KERNEL, sizeof(struct ec_device));
+ edev = kmalloc(sizeof(struct ec_device), GFP_KERNEL);
                         if (edev == NULL) {
                                 printk("af_ec: memory squeeze.\n");
                                 dev_put(dev);

-
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 : Sun Jul 23 2000 - 21:00:15 EST