Skip to contentSkip to conversation

initializing chip->wq in cfi_cmdset_0002.c

PATCH David Byron 2 participants 2 messages Jul 1, 2006 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

I'm using cfi_cmdset_0002.c to access a flash chip and I ran into an oops from trying to dereference a null pointer. I found a fix for it, but I feel like there must be something I don't understand. Seems like other folks would have run into this as well.

The crash comes with the call to wake_up(&chip->wq) on the last line of put_chip. I can't see anywhere that this data structure is initialized. I looked at some of the other cfi_cmdset* files and decided that

(quoted diff) +0 -0

b/drivers/mtd/chips/cfi_cmdset_0002.c
index 9885726..8a390b3 100644

drivers/mtd/chips/cfi_cmdset_0002.c +0 -0
@@ -320,6 +320,7 @@ #endif
 		cfi->chips[i].word_write_time =

1<<cfi->cfiq->WordWriteTimeoutTyp;
cfi->chips[i].buffer_write_time =
1<<cfi->cfiq->BufWriteTimeoutTyp;
cfi->chips[i].erase_time =
1<<cfi->cfiq->BlockEraseTimeoutTyp;
+ init_waitqueue_head(&cfi->chips[i].wq);
}

map->fldrv = &cfi_amdstd_chipdrv;

was a good place to initialize. It fixes the oops for me. Can someone confirm that this makes sense?

Thanks much.

-DB

#1 lore raw
Quoted 26 lines · David Byron

I'm using cfi_cmdset_0002.c to access a flash chip and I ran into an oops from trying to dereference a null pointer. I found a fix for it, but I feel like there must be something I don't understand. Seems like other folks would have run into this as well.

The crash comes with the call to wake_up(&chip->wq) on the last line of put_chip. I can't see anywhere that this data structure is initialized. I looked at some of the other cfi_cmdset* files and decided that

drivers/mtd/chips/cfi_cmdset_0002.c +1 -0
index 9885726..8a390b3 100644
@@ -320,6 +320,7 @@ #endif
 		cfi->chips[i].word_write_time =
 1<<cfi->cfiq->WordWriteTimeoutTyp;
 		cfi->chips[i].buffer_write_time =
 1<<cfi->cfiq->BufWriteTimeoutTyp;
 		cfi->chips[i].erase_time =
 1<<cfi->cfiq->BlockEraseTimeoutTyp;
+		init_waitqueue_head(&cfi->chips[i].wq);
drivers/mtd/chips/cfi_cmdset_0002.c +0 -0
 	}
 
 	map->fldrv = &cfi_amdstd_chipdrv;
Quoted 2 lines

was a good place to initialize. It fixes the oops for me. Can someone confirm that this makes sense?

Yes, it makes sense. Please fix your mailer not to line wrap patches. Makes them hard to read and impossible to apply. Please resend !

I'm sure we fixed that some time ago. Might have been lost when we switched from CVS to git. David ?

tglx