public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Peterson <dsp@llnl.gov>
To: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: linux-kernel@vger.kernel.org, axboe@suse.de, davej@suse.de
Subject: Re: [PATCH] fixes for linked list bugs in block I/O code
Date: Wed, 7 May 2003 17:38:09 -0700	[thread overview]
Message-ID: <200305071738.09209.dsp@llnl.gov> (raw)
In-Reply-To: <Pine.SOL.4.30.0305080214580.5113-100000@mion.elka.pw.edu.pl>

On Wednesday 07 May 2003 05:26 pm, Bartlomiej Zolnierkiewicz wrote:
> On Wed, 7 May 2003, Dave Peterson wrote:
> > On Wednesday 07 May 2003 04:42 pm, Bartlomiej Zolnierkiewicz wrote:
> > > > ========== START OF 2.5.69 PATCH FOR drivers/block/ll_rw_blk.c
> > > > =========== --- ll_rw_blk.c.old     Wed May  7 15:55:18 2003
> > > > +++ ll_rw_blk.c.new     Wed May  7 16:01:56 2003
> > > > @@ -1721,6 +1721,7 @@
> > > >                                 break;
> > > >                         }
> > > >
> > > > +                       bio->bi_next = req->biotail->bi_next;
> > >
> > > This is simply wrong, look at the line below.
> > >
> > > >                         req->biotail->bi_next = bio;
> > >
> > > req->bio - first bio
> > > req->bio->bi_next - next bio
> > > ...
> > > req->biotail - last bio
> > >
> > > so req->biotail->bi_next should be NULL
> >
> > I believe it is correct.  Assuming that the list is initially in a
> > sane state, req->biotail->bi_next will be NULL immediately before
> > executing the statement that I added.  Therefore, my fix will set
> > bio->bi_next to NULL, which is what we want because bio becomes the
> > new end of the list.
>
> Yes, but bio->bi_next is a NULL already.

I think assuming this is bad programming form.  You are assuming that
the memory allocator zeros out newly allocated memory.  Though your
assumption may be correct, it's always possible that this behavior will
change some day (perhaps for efficiency reasons), causing your code
to break.  In my opinion, the savings of a few cpu clock cycles that
you gain by omitting the initialization isn't worth compromising
the robustness of your code.

-Dave

  reply	other threads:[~2003-05-08  0:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-07 23:22 [PATCH] fixes for linked list bugs in block I/O code Dave Peterson
2003-05-07 23:42 ` Bartlomiej Zolnierkiewicz
2003-05-08  0:09   ` Dave Peterson
2003-05-08  0:26     ` Bartlomiej Zolnierkiewicz
2003-05-08  0:38       ` Dave Peterson [this message]
2003-05-08  1:17         ` Bartlomiej Zolnierkiewicz
2003-05-08 17:47           ` Dave Peterson
2003-05-08  6:29 ` Jens Axboe
2003-05-08 18:06   ` Dave Peterson

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=200305071738.09209.dsp@llnl.gov \
    --to=dsp@llnl.gov \
    --cc=B.Zolnierkiewicz@elka.pw.edu.pl \
    --cc=axboe@suse.de \
    --cc=davej@suse.de \
    --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