mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Korty <joe.korty@ccur.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: memset argument order misuses
Date: Sat, 12 Feb 2005 22:15:32 -0500	[thread overview]
Message-ID: <20050213031532.GA8656@tsunami.ccur.com> (raw)

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);

             reply	other threads:[~2005-02-13  3:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-13  3:15 Joe Korty [this message]
2005-02-13  5:29 ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050213031532.GA8656@tsunami.ccur.com \
    --to=joe.korty@ccur.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®