From: Paulo Marques <pmarques@grupopie.com>
To: Panagiotis Issaris <takis@lumumba.uhasselt.be>
Cc: linux-kernel@vger.kernel.org, len.brown@intel.com,
chas@cmf.nrl.navy.mil, miquel@df.uba.ar, kkeil@suse.de,
benh@kernel.crashing.org, video4linux-list@redhat.com,
rmk+mmc@arm.linux.org.uk, Neela.Kolli@engenio.com,
jgarzik@pobox.com, vandrove@vc.cvut.cz, adaplas@pol.net,
thomas@winischhofer.net, weissg@vienna.at, philb@gnu.org,
linux-pcmcia@lists.infradead.org, jkmaline@cc.hut.fi,
paulus@samba.org
Subject: Re: [PATCH] drivers: Conversions from kmalloc+memset to k(z|c)alloc.
Date: Wed, 19 Jul 2006 14:53:31 +0100 [thread overview]
Message-ID: <44BE395B.2090001@grupopie.com> (raw)
In-Reply-To: <20060719004659.GA30823@lumumba.uhasselt.be>
Panagiotis Issaris wrote:
> [...]
> --- a/drivers/char/consolemap.c
> +++ b/drivers/char/consolemap.c
> @@ -192,11 +192,9 @@ static void set_inverse_transl(struct vc
> q = p->inverse_translations[i];
>
> if (!q) {
> - q = p->inverse_translations[i] = (unsigned char *)
> - kmalloc(MAX_GLYPH, GFP_KERNEL);
> + q = p->inverse_translations[i] = kzalloc(MAX_GLYPH, GFP_KERNEL);
> if (!q) return;
> }
> - memset(q, 0, MAX_GLYPH);
This changes semantics here. Before, the data pointed by q was always
cleared whether it was malloc'ed or not. Now it is only cleared if it is
malloc'ed. I haven't checked the code to find out if this is ok, though.
> @@ -2704,8 +2702,7 @@ static void cardmap_set(struct cardmap *
> if (p == NULL || (nr >> p->shift) >= CARDMAP_WIDTH) {
> do {
> /* need a new top level */
> - struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL);
> - memset(np, 0, sizeof(*np));
> + struct cardmap *np = kzalloc(sizeof(*np), GFP_KERNEL);
> np->ptr[0] = p;
> if (p != NULL) {
> np->shift = p->shift + CARDMAP_ORDER;
> @@ -2719,8 +2716,7 @@ static void cardmap_set(struct cardmap *
> while (p->shift > 0) {
> i = (nr >> p->shift) & CARDMAP_MASK;
> if (p->ptr[i] == NULL) {
> - struct cardmap *np = kmalloc(sizeof(*np), GFP_KERNEL);
> - memset(np, 0, sizeof(*np));
> + struct cardmap *np = kzalloc(sizeof(*np), GFP_KERNEL);
> np->shift = p->shift - CARDMAP_ORDER;
> np->parent = p;
> p->ptr[i] = np;
This is not your fault, but this code is using the return value from
kmalloc (or kzalloc, now) without checking for NULL.
> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
> index 76edbb6..71d4743 100644
> --- a/drivers/scsi/megaraid.c
> +++ b/drivers/scsi/megaraid.c
> @@ -4487,8 +4487,7 @@ mega_internal_command(adapter_t *adapter
> scmd = &adapter->int_scmd;
> memset(scmd, 0, sizeof(Scsi_Cmnd));
>
> - sdev = kmalloc(sizeof(struct scsi_device), GFP_KERNEL);
> - memset(sdev, 0, sizeof(struct scsi_device));
> + sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
> scmd->device = sdev;
>
> scmd->device->host = adapter->host;
Same here.
> --- a/drivers/video/offb.c
> +++ b/drivers/video/offb.c
> @@ -376,13 +376,12 @@ static void __init offb_init_fb(const ch
>
> size = sizeof(struct fb_info) + sizeof(u32) * 17;
>
> - info = kmalloc(size, GFP_ATOMIC);
> + info = kzalloc(size, GFP_ATOMIC);
>
> if (info == 0) {
Again, not your fault, but "info == 0"? If you're doing a new version of
the patch, please change this to NULL or !info, so that we don't confuse
human readers :)
--
Paulo Marques - www.grupopie.com
"I can picture in my mind a world without war, a world
without hate. And I can picture us attacking that world,
because they'd never expect it."
next prev parent reply other threads:[~2006-07-19 13:53 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-19 0:46 [PATCH] drivers: Conversions from kmalloc+memset to k(z|c)alloc Panagiotis Issaris
2006-07-19 0:59 ` Alexey Dobriyan
2006-07-19 1:38 ` Panagiotis Issaris
2006-07-19 2:40 ` Daniel K.
2006-07-19 8:38 ` Pekka Enberg
2006-07-20 17:25 ` Panagiotis Issaris
2006-07-20 17:49 ` Pekka Enberg
2006-07-19 12:17 ` Antonino A. Daplas
2006-07-19 12:52 ` Paul Mackerras
2006-07-19 13:53 ` Pekka Enberg
2006-07-19 13:53 ` Paulo Marques [this message]
2006-07-20 18:03 ` Panagiotis Issaris
-- strict thread matches above, loose matches on Subject: below --
2006-07-20 19:05 Panagiotis Issaris
2006-07-21 6:50 ` Rolf Eike Beer
2006-07-21 6:58 ` Pekka Enberg
2006-07-21 7:05 ` Jeff Garzik
2006-07-21 9:09 ` Stefan Richter
2006-07-21 10:20 ` Jesper Juhl
2006-07-21 10:35 ` Panagiotis Issaris
2006-07-21 10:38 ` Pekka J Enberg
2006-07-21 10:55 ` Stefan Richter
2006-07-22 17:58 ` Tomasz Kłoczko
2006-07-22 18:25 ` Stefan Richter
2006-07-22 18:35 ` Tomasz Kłoczko
2006-07-22 20:02 ` Jeff Garzik
2006-07-22 20:55 ` Tomasz Kłoczko
2006-07-23 11:20 ` Alexey Dobriyan
2006-07-23 17:55 ` Tomasz Kłoczko
2006-07-23 18:24 ` Michael Buesch
2006-07-24 0:10 ` Tomasz Kłoczko
2006-07-24 0:49 ` Tomasz Kłoczko
2006-07-23 15:16 ` Stefan Richter
2006-07-23 18:09 ` Tomasz Kłoczko
2006-07-21 10:53 ` Stefan Richter
2006-07-21 11:09 ` Stefan Richter
2006-07-21 21:16 ` Jeff Garzik
2006-07-21 21:15 ` Jeff Garzik
2006-07-22 6:20 ` Stefan Richter
2006-07-21 10:21 ` Daniel K.
2006-07-21 10:30 ` Panagiotis Issaris
2006-07-21 11:12 ` Rolf Eike Beer
2006-07-21 12:35 ` Dmitry Torokhov
2006-07-21 12:39 ` Panagiotis Issaris
2006-07-22 2:22 Brown, Len
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=44BE395B.2090001@grupopie.com \
--to=pmarques@grupopie.com \
--cc=Neela.Kolli@engenio.com \
--cc=adaplas@pol.net \
--cc=benh@kernel.crashing.org \
--cc=chas@cmf.nrl.navy.mil \
--cc=jgarzik@pobox.com \
--cc=jkmaline@cc.hut.fi \
--cc=kkeil@suse.de \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pcmcia@lists.infradead.org \
--cc=miquel@df.uba.ar \
--cc=paulus@samba.org \
--cc=philb@gnu.org \
--cc=rmk+mmc@arm.linux.org.uk \
--cc=takis@lumumba.uhasselt.be \
--cc=thomas@winischhofer.net \
--cc=vandrove@vc.cvut.cz \
--cc=video4linux-list@redhat.com \
--cc=weissg@vienna.at \
/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