From: Tony Battersby Date: Tue, 20 Jan 2009 22:00:09 +0000 (-0500) Subject: [SCSI] sg: fix races with ioctl(SG_IO) X-Git-Tag: v2.6.30-rc1~641^2~97 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2dd3b4cea335713b58996bb07b3abcde1175f47;p=pandora-kernel.git [SCSI] sg: fix races with ioctl(SG_IO) sg_io_owned needs to be set before the command is sent to the midlevel; otherwise, a quickly-completing command may cause a different CPU to see "srp->done == 1 && !srp->sg_io_owned", which would lead to incorrect behavior. Check srp->done and set srp->orphan while holding rq_list_lock to prevent races with sg_rq_end_io(). There is no need to check sfp->closed from read/write/ioctl/poll/etc. since the kernel guarantees that this won't happen. The usefulness of sg_srp_done() was questionable before; now it is definitely not needed. Signed-off-by: Tony Battersby Acked-by: Douglas Gilbert Signed-off-by: James Bottomley --- Reading git-diff-tree failed