From: Pete Zaitcev <zaitcev@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: zaitcev@redhat.com
Subject: Would the father of init_mem_lth please stand up
Date: Fri, 7 Dec 2001 23:40:48 -0500 [thread overview]
Message-ID: <20011207234048.A31442@devserv.devel.redhat.com> (raw)
Really someone needs slapping across. What kind of code is that
(in 2.5.1-pre6):
drivers/scsi/sd.c:sd_init()
/* allocate memory */
#define init_mem_lth(x,n) x = kmalloc((n) * sizeof(*x), GFP_ATOMIC)
#define zero_mem_lth(x,n) memset(x, 0, (n) * sizeof(*x))
init_mem_lth(rscsi_disks, sd_template.dev_max);
init_mem_lth(sd_sizes, maxparts);
init_mem_lth(sd_blocksizes, maxparts);
init_mem_lth(sd, maxparts);
init_mem_lth(sd_gendisks, N_USED_SD_MAJORS);
init_mem_lth(sd_max_sectors, sd_template.dev_max << 4);
if (!rscsi_disks || !sd_sizes || !sd_blocksizes || !sd || !sd_gendisks)
goto cleanup_mem;
#undef init_mem_lth
#undef zero_mem_lth
.....................
cleanup_mem:
kfree(sd_gendisks);
kfree(sd);
kfree(sd_blocksizes);
kfree(sd_sizes);
kfree(rscsi_disks);
However, it's not only about the puking and keyboard cleanups.
The code is buggy as well. Scenario:
0. User inserts a large number of FC-AL adapters with 56 disks each
1. modprobe sd_mod
No SCSI hosts, sd_init() is NOT called.
2. modprobe qla_something
sd_init is called and fails on sd_gendisks. modprobe fails.
sd_sizes, sd_blocksizes, etc. are LEFT DANGLING
3. modprobe qla_something
sd_init is called and fails on sd_sizes.
kfree is called with a bunch of dangling pointers
I stringly urge Linus to drop this so-called "cleanup" from 2.5.1.
No doubt, the existing code was bad. I fixed it somewhat for 2.4,
and am feeding it to Marcelo. I can forward-port that to 2.5
if anyone is interested.
-- Pete
next reply other threads:[~2001-12-08 4:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-08 4:40 Pete Zaitcev [this message]
2001-12-08 8:52 ` Would the father of init_mem_lth please stand up Jens Axboe
2001-12-08 11:07 ` Alan Cox
2001-12-08 16:36 ` Pete Zaitcev
2001-12-08 20:43 ` Alan Cox
2001-12-08 11:47 ` Eric Lammerts
2001-12-08 16:32 ` Pete Zaitcev
-- strict thread matches above, loose matches on Subject: below --
2001-12-08 19:16 Andries.Brouwer
2001-12-08 20:43 Andries.Brouwer
2001-12-08 20:58 ` Alan Cox
[not found] <mailman.1007844368.15393.linux-kernel2news@redhat.com>
2001-12-08 21:56 ` Pete Zaitcev
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=20011207234048.A31442@devserv.devel.redhat.com \
--to=zaitcev@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.