projects/linux·commit b8ea2cb5

[BLOCK] elevator init fixes

b8ea2cb5 · Zachary Amsden <[email protected]> · 2005-11-09 13:23:01 +01:00

I got a panic in the elevator code, backtrace :

Unable to handle kernel NULL pointer dereference at virtual address 00000060
..
EIP is at elevator_put+0x0/0x30 (null elevator_type passed)
..
elevator_init+0x38
blk_init_queu_node+0xc9
floppy_init+0xdb
do_initcalls+0x23
init+0x10a
init+0x0

Clearly if the kmalloc here fails, e->elevator_type is not yet set; this
appears to be the correct fix, but I think I probably hit the second case
due to a race condition.  Someone more familiar with the elevator code
should look at this more closely until I can determine if I can reproduce.

Signed-off-by: Zachary Amsden <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
Commit
b8ea2cb5120a92fe63053a2896be42abbb919a76
Parents
cd52d1ee

Changes

1 files changed · +2 −2

FileStatusAddDelContent
block/elevator.cmodified+2−2View file

block/elevator.c

View file
diff --git a/block/elevator.c b/block/elevator.c
index d4a49a3..23cfbe5 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -190,14 +190,14 @@ int elevator_init(request_queue_t *q, char *name)
eq = kmalloc(sizeof(struct elevator_queue), GFP_KERNEL);
if (!eq) {
- elevator_put(e->elevator_type);
+ elevator_put(e);
return -ENOMEM;
}
ret = elevator_attach(q, e, eq);
if (ret) {
kfree(eq);
- elevator_put(e->elevator_type);
+ elevator_put(e);
}
return ret;