This fixes a problem with drivers that have request on the stack for
some operations, like IDE. If we wake before releasing the request, the
stack may have already disappeared beneath us when the rest of
end_that_request_last() is run.
Fix by making sure the completion is done _last_.
void end_that_request_last(struct request *req)
{
struct gendisk *disk = req->rq_disk;
- if (req->waiting)
- complete(req->waiting);
+ struct completion *waiting = req->waiting;
if (disk) {
unsigned long duration = jiffies - req->start_time;
disk_stat_dec(disk, in_flight);
}
__blk_put_request(req->q, req);
+ /* Do this LAST! The structure may be freed immediately afterwards */
+ if (waiting)
+ complete(waiting);
}
int __init blk_dev_init(void)