From: Denis Vlasenko <vda@ilport.com.ua>
To: Jesper Juhl <juhl-lkml@dif.dk>,
Maciej Soltysiak <solt2@dns.toxicfilms.tv>
Cc: "James P. Ketrenos" <ipw2100-admin@linux.intel.com>,
netdev@oss.sgi.com, "David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org
Subject: Re: [2.6.12-rc1-mm4] swapped memset arguments
Date: Tue, 5 Apr 2005 18:37:39 +0300 [thread overview]
Message-ID: <200504051837.39561.vda@ilport.com.ua> (raw)
In-Reply-To: <Pine.LNX.4.62.0504030035190.2525@dragon.hyggekrogen.localhost>
[-- Attachment #1: Type: text/plain, Size: 564 bytes --]
On Sunday 03 April 2005 01:38, Jesper Juhl wrote:
> On Sat, 2 Apr 2005, Maciej Soltysiak wrote:
>
> > Hi,
> >
> > out of boredom I grepped 2.6.12-rc1-mm4 for swapped memset arguments.
> > I found one:
> >
> > # grep -nr "memset.*\,\(\ \|\)0\(\ \|\));" *
> > net/ieee80211/ieee80211_tx.c:226: memset(txb, sizeof(struct ieee80211_txb), 0);
> >
> And here's a patch :
>
>
> Fix swapped memset() arguments in net/ieee80211/ieee80211_tx.c
> found by Maciej Soltysiak.
This one will stop these from happening again.
(Well, at least on i386)...
--
vda
[-- Attachment #2: string.diff --]
[-- Type: text/x-diff, Size: 951 bytes --]
--- linux-2.6.11.src/include/asm-i386/string.h.orig Thu Mar 3 09:31:08 2005
+++ linux-2.6.11.src/include/asm-i386/string.h Tue Apr 5 18:34:28 2005
@@ -316,8 +345,16 @@ __asm__ __volatile__(
return s;
}
-/* we might want to write optimized versions of these later */
-#define __constant_count_memset(s,c,count) __memset_generic((s),(c),(count))
+/*
+ * we might want to write optimized versions of this later
+ * for mow, just prevent common mistake of memset(a,c,0)
+ */
+void BUG_memset_with_zero_length(void);
+static inline void * __constant_count_memset(void * s, int c, size_t count)
+{
+ if(!count) BUG_memset_with_zero_length();
+ return __memset_generic(s,c,count);
+}
/*
* memset(x,0,y) is a reasonably common thing to do, so we want to fill
@@ -376,6 +413,7 @@ static inline void * __constant_c_and_co
{
switch (count) {
case 0:
+ BUG_memset_with_zero_length();
return s;
case 1:
*(unsigned char *)s = pattern;
prev parent reply other threads:[~2005-04-05 15:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <74334709.20050402233007@dns.toxicfilms.tv>
2005-04-02 22:38 ` [2.6.12-rc1-mm4] swapped memset arguments Jesper Juhl
2005-04-05 15:37 ` Denis Vlasenko [this message]
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=200504051837.39561.vda@ilport.com.ua \
--to=vda@ilport.com.ua \
--cc=davem@davemloft.net \
--cc=ipw2100-admin@linux.intel.com \
--cc=juhl-lkml@dif.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@oss.sgi.com \
--cc=solt2@dns.toxicfilms.tv \
/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;
as well as URLs for NNTP newsgroup(s).