mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* memset argument order misuses
@ 2005-02-13  3:15 Joe Korty
  2005-02-13  5:29 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Joe Korty @ 2005-02-13  3:15 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

Hi Andrew,
A simple 'grep memset.*\<0);' shows argument order errors in several uses
of memset.

This grep was inspired by Al Viro's recent patch, megaraid_mbox fix,
which fixed this problem in the megaraid driver.

Completely untested.

Regards,
Joe
--
"Money can buy bandwidth, but latency is forever" -- John Mashey



diff -Nura base/drivers/s390/block/dasd_genhd.c new/drivers/s390/block/dasd_genhd.c
--- base/drivers/s390/block/dasd_genhd.c	2004-12-24 16:35:24.000000000 -0500
+++ new/drivers/s390/block/dasd_genhd.c	2005-02-12 21:55:48.546192009 -0500
@@ -149,8 +149,8 @@
 	 * Can't call delete_partitions directly. Use ioctl.
 	 * The ioctl also does locking and invalidation.
 	 */
-	memset(&bpart, sizeof(struct blkpg_partition), 0);
-	memset(&barg, sizeof(struct blkpg_ioctl_arg), 0);
+	memset(&bpart, 0, sizeof(struct blkpg_partition));
+	memset(&barg, 0, sizeof(struct blkpg_ioctl_arg));
 	barg.data = &bpart;
 	barg.op = BLKPG_DEL_PARTITION;
 	for (bpart.pno = device->gdp->minors - 1; bpart.pno > 0; bpart.pno--)
diff -Nura base/drivers/s390/cio/cmf.c new/drivers/s390/cio/cmf.c
--- base/drivers/s390/cio/cmf.c	2004-12-24 16:33:48.000000000 -0500
+++ new/drivers/s390/cio/cmf.c	2005-02-12 21:56:08.430256458 -0500
@@ -526,7 +526,7 @@
 	time = get_clock() - cdev->private->cmb_start_time;
 	spin_unlock_irqrestore(cdev->ccwlock, flags);
 
-	memset(data, sizeof(struct cmbdata), 0);
+	memset(data, 0, sizeof(struct cmbdata));
 
 	/* we only know values before device_busy_time */
 	data->size = offsetof(struct cmbdata, device_busy_time);
@@ -736,7 +736,7 @@
 	time = get_clock() - cdev->private->cmb_start_time;
 	spin_unlock_irqrestore(cdev->ccwlock, flags);
 
-	memset (data, sizeof(struct cmbdata), 0);
+	memset (data, 0, sizeof(struct cmbdata));
 
 	/* we only know values before device_busy_time */
 	data->size = offsetof(struct cmbdata, device_busy_time);
diff -Nura base/drivers/s390/cio/css.c new/drivers/s390/cio/css.c
--- base/drivers/s390/cio/css.c	2005-02-12 21:51:28.000000000 -0500
+++ new/drivers/s390/cio/css.c	2005-02-12 21:56:20.066538550 -0500
@@ -527,7 +527,7 @@
 	new_slow_sch = kmalloc(sizeof(struct slow_subchannel), GFP_ATOMIC);
 	if (!new_slow_sch)
 		return -ENOMEM;
-	memset(new_slow_sch, sizeof(struct slow_subchannel), 0);
+	memset(new_slow_sch, 0, sizeof(struct slow_subchannel));
 	new_slow_sch->schid = schid;
 	spin_lock_irqsave(&slow_subchannel_lock, flags);
 	list_add_tail(&new_slow_sch->slow_list, &slow_subchannels_head);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: memset argument order misuses
  2005-02-13  3:15 memset argument order misuses Joe Korty
@ 2005-02-13  5:29 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2005-02-13  5:29 UTC (permalink / raw)
  To: joe.korty; +Cc: linux-kernel, Heiko Carstens, Martin Schwidefsky

Joe Korty <joe.korty@ccur.com> wrote:
>
> Hi Andrew,
> A simple 'grep memset.*\<0);' shows argument order errors in several uses
> of memset.
> 
> This grep was inspired by Al Viro's recent patch, megaraid_mbox fix,
> which fixed this problem in the megaraid driver.
> 

heh.  Lsydexic s/390 developers.  Thanks, I guess we should scoot this into
2.6.11.


> 
> Regards,
> Joe
> --
> "Money can buy bandwidth, but latency is forever" -- John Mashey
> 
> 
> 
> diff -Nura base/drivers/s390/block/dasd_genhd.c new/drivers/s390/block/dasd_genhd.c
> --- base/drivers/s390/block/dasd_genhd.c	2004-12-24 16:35:24.000000000 -0500
> +++ new/drivers/s390/block/dasd_genhd.c	2005-02-12 21:55:48.546192009 -0500
> @@ -149,8 +149,8 @@
>  	 * Can't call delete_partitions directly. Use ioctl.
>  	 * The ioctl also does locking and invalidation.
>  	 */
> -	memset(&bpart, sizeof(struct blkpg_partition), 0);
> -	memset(&barg, sizeof(struct blkpg_ioctl_arg), 0);
> +	memset(&bpart, 0, sizeof(struct blkpg_partition));
> +	memset(&barg, 0, sizeof(struct blkpg_ioctl_arg));
>  	barg.data = &bpart;
>  	barg.op = BLKPG_DEL_PARTITION;
>  	for (bpart.pno = device->gdp->minors - 1; bpart.pno > 0; bpart.pno--)
> diff -Nura base/drivers/s390/cio/cmf.c new/drivers/s390/cio/cmf.c
> --- base/drivers/s390/cio/cmf.c	2004-12-24 16:33:48.000000000 -0500
> +++ new/drivers/s390/cio/cmf.c	2005-02-12 21:56:08.430256458 -0500
> @@ -526,7 +526,7 @@
>  	time = get_clock() - cdev->private->cmb_start_time;
>  	spin_unlock_irqrestore(cdev->ccwlock, flags);
>  
> -	memset(data, sizeof(struct cmbdata), 0);
> +	memset(data, 0, sizeof(struct cmbdata));
>  
>  	/* we only know values before device_busy_time */
>  	data->size = offsetof(struct cmbdata, device_busy_time);
> @@ -736,7 +736,7 @@
>  	time = get_clock() - cdev->private->cmb_start_time;
>  	spin_unlock_irqrestore(cdev->ccwlock, flags);
>  
> -	memset (data, sizeof(struct cmbdata), 0);
> +	memset (data, 0, sizeof(struct cmbdata));
>  
>  	/* we only know values before device_busy_time */
>  	data->size = offsetof(struct cmbdata, device_busy_time);
> diff -Nura base/drivers/s390/cio/css.c new/drivers/s390/cio/css.c
> --- base/drivers/s390/cio/css.c	2005-02-12 21:51:28.000000000 -0500
> +++ new/drivers/s390/cio/css.c	2005-02-12 21:56:20.066538550 -0500
> @@ -527,7 +527,7 @@
>  	new_slow_sch = kmalloc(sizeof(struct slow_subchannel), GFP_ATOMIC);
>  	if (!new_slow_sch)
>  		return -ENOMEM;
> -	memset(new_slow_sch, sizeof(struct slow_subchannel), 0);
> +	memset(new_slow_sch, 0, sizeof(struct slow_subchannel));
>  	new_slow_sch->schid = schid;
>  	spin_lock_irqsave(&slow_subchannel_lock, flags);
>  	list_add_tail(&new_slow_sch->slow_list, &slow_subchannels_head);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-02-13  5:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-13  3:15 memset argument order misuses Joe Korty
2005-02-13  5:29 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®