public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Would the father of init_mem_lth please stand up
@ 2001-12-08  4:40 Pete Zaitcev
  2001-12-08  8:52 ` Jens Axboe
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Pete Zaitcev @ 2001-12-08  4:40 UTC (permalink / raw)
  To: linux-kernel; +Cc: zaitcev

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

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Would the father of init_mem_lth please stand up
@ 2001-12-08 19:16 Andries.Brouwer
  0 siblings, 0 replies; 11+ messages in thread
From: Andries.Brouwer @ 2001-12-08 19:16 UTC (permalink / raw)
  To: linux-kernel, zaitcev

    From: Pete Zaitcev <zaitcev@redhat.com>

    Really someone needs slapping across. What kind of code is that
    (in 2.5.1-pre6):

    drivers/scsi/sd.c:sd_init()

...
    The code is buggy. Scenario:


Yes, you are right, the code is buggy.
It looks like part of something I did a few months ago
for 2.4.6 or so. I tend to give the guarantee "correctness
preserved". So, the conclusion must be that before this
change was applied the code had precisely the same bug.

Andries

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Would the father of init_mem_lth please stand up
@ 2001-12-08 20:43 Andries.Brouwer
  2001-12-08 20:58 ` Alan Cox
  0 siblings, 1 reply; 11+ messages in thread
From: Andries.Brouwer @ 2001-12-08 20:43 UTC (permalink / raw)
  To: alan; +Cc: linux-kernel

    From: Alan Cox <alan@lxorguk.ukuu.org.uk>

    > Really someone needs slapping across. What kind of code is that
    > (in 2.5.1-pre6):

    Whoever merged that crap also wants a good kicking. First we have the joke
    ps/2 merge, now this. Is Linus trying to force someone to take over or is
    small children combined with a pending christmas really the doom that some
    folks claim 8)

Alan, Alan,

Please calm down. Linus is doing a good job, and whenever things
go slightly wrong someone comes along to point out the flaw.
Moreover, I can assure you that pending christmas and small children
really is a very nice time.
And then, my beautiful code is not at all crap that should not
have been applied. It fixes a real bug. But there was another bug
there that it left, namely that the freed pointers should have been
zeroed, so that nobody can come and use them with random results.
If nobody else does it, I'll send also that small fix, but maybe
not today.

Andries

^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <mailman.1007844368.15393.linux-kernel2news@redhat.com>]

end of thread, other threads:[~2001-12-08 21:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-08  4:40 Would the father of init_mem_lth please stand up Pete Zaitcev
2001-12-08  8:52 ` 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

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