public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bsg: bidi bio map failure fix
@ 2008-02-12 20:40 Pete Wyckoff
  2008-02-12 21:12 ` James Bottomley
  2008-02-14 11:57 ` FUJITA Tomonori
  0 siblings, 2 replies; 10+ messages in thread
From: Pete Wyckoff @ 2008-02-12 20:40 UTC (permalink / raw)
  To: Jens Axboe; +Cc: FUJITA Tomonori, linux-scsi

If blk_rq_map_user requires more than one bio, and fails mapping
somewhere after the first bio, it will return with rq->bio set to
non-NULL, but it will have already unmapped the partial bio.  The
"out:" error exit section will see the non-null bio and try to unmap
it again, triggering a mapcount bug via bad_page().

Signed-off-by: Pete Wyckoff <pw@osc.edu>
---
 block/bsg.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/block/bsg.c b/block/bsg.c
index 3337125..bba7154 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -295,8 +295,10 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr)
 
 		dxferp = (void*)(unsigned long)hdr->din_xferp;
 		ret =  blk_rq_map_user(q, next_rq, dxferp, hdr->din_xfer_len);
-		if (ret)
+		if (ret) {
+			next_rq->bio = NULL;  /* do not unmap twice */
 			goto out;
+		}
 	}
 
 	if (hdr->dout_xfer_len) {
-- 
1.5.3.8


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-02-18 17:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-12 20:40 [PATCH] bsg: bidi bio map failure fix Pete Wyckoff
2008-02-12 21:12 ` James Bottomley
2008-02-18 12:55   ` Jens Axboe
2008-02-18 14:37     ` FUJITA Tomonori
2008-02-18 14:46       ` Jens Axboe
2008-02-18 15:09         ` James Bottomley
2008-02-18 15:24           ` FUJITA Tomonori
2008-02-18 17:25           ` Jens Axboe
2008-02-18 14:54       ` James Bottomley
2008-02-14 11:57 ` FUJITA Tomonori

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