From: Andries.Brouwer@cwi.nl
To: Andries.Brouwer@cwi.nl, linux-kernel@vger.kernel.org, wrlk@riede.org
Subject: Re: [PATCH] fix for ide-scsi crash
Date: Mon, 19 Jan 2004 23:56:40 +0100 (MET) [thread overview]
Message-ID: <UTC200401192256.i0JMueG18732.aeb@smtp.cwi.nl> (raw)
From: Willem Riede <wrlk@riede.org>
> - spin_unlock_irq(cmd->device->host->host_lock);
> - (void) ide_do_drive_cmd (drive, rq, ide_end);
> - spin_lock_irq(cmd->device->host->host_lock);
> + {
> + struct Scsi_Host *host = cmd->device->host;
> + spin_unlock_irq(host->host_lock);
> + (void) ide_do_drive_cmd(drive, rq, ide_end);
> + spin_lock_irq(host->host_lock);
> + }
Interesting. So cmd->device->host changed after ide_do_drive_cmd?
It is a race.
ide_do_drive_cmd(..., ide_end) does not wait for I/O to finish,
but when I/O finishes cmd is freed. So, if the device is quick
and the kernel is slow - maybe a timer interrupt in between -
the command can have finished before the spin_lock_irq() is done.
That may be a problem if the scsi error handler has to spring
into action for this command, as it uses that field extensively...
> - if (pc) kfree (pc);
> - if (rq) kfree (rq);
> + kfree (pc);
> + kfree (rq);
So it is OK to rely on the NULL check in kfree?
Yes. Many years ago I regarded it as ugly to do so, but by now
it is common usage.
Andries
next reply other threads:[~2004-01-19 22:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-19 22:56 Andries.Brouwer [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-01-20 17:08 Pascal Schmidt
2004-01-20 20:01 ` Andries Brouwer
2004-01-20 20:58 ` Pascal Schmidt
[not found] <1fMNb-6UA-15@gated-at.bofh.it>
[not found] ` <1fYEB-pz-23@gated-at.bofh.it>
[not found] ` <1g4Ao-60b-25@gated-at.bofh.it>
2004-01-20 14:59 ` Pascal Schmidt
2004-01-20 19:04 ` bill davidsen
2004-01-20 9:44 Andries.Brouwer
2004-01-20 12:04 ` Pascal Schmidt
2004-01-20 13:56 ` Jens Axboe
2004-01-20 17:56 ` Linus Torvalds
2004-01-20 18:46 ` Ben Pfaff
2004-01-19 18:51 Pascal Schmidt
2004-01-20 7:32 ` Linus Torvalds
2004-01-20 13:54 ` Jens Axboe
2004-01-19 4:35 Andries.Brouwer
2004-01-19 22:35 ` Willem Riede
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=UTC200401192256.i0JMueG18732.aeb@smtp.cwi.nl \
--to=andries.brouwer@cwi.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=wrlk@riede.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
all inboxes | Powered by JetHome®