This can't be right.. I'm playing around with some filesystem code in my kernel module and I want to open a device with blkdev_get(...);
Kept getting "Killed" when I ran my test code, the simplified, functional nugget of which is this:
Code:
fmode_t mode = FMODE_READ | FMODE_WRITE;
struct block_device* candidate = blkdev_get_by_path( "/dev/sda", mode, 0 );
if ( candidate == NULL )
{
// [report failure]
continue;
}
blkdev_put( candidate, mode );
no matter what I tried, when I ran it I got "Killed" and always with this kind of dump:
Code:
[ 80.505214] BUG: kernel NULL pointer dereference, address: 000000000000000b
[ 80.505248] #PF: supervisor write access in kernel mode
[ 80.505266] #PF: error_code(0x0002) - not-present page
[ 80.505284] PGD 0 P4D 0
[ 80.505297] Oops: 0002 [#1] SMP PTI
[ 80.505312] CPU: 2 PID: 2013 Comm: do Tainted: G OE 5.3.0-40-generic #32-Ubuntu
[ 80.505342] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[ 80.505387] RIP: 0010:mutex_lock+0x1e/0x40
[ 80.505407] Code: c3 66 66 2e 0f 1f 84 00 00 00 00 00 66 66 66 66 90 55 48 89 e5 41 54 49 89 fc e8 8d de ff ff 31 c0 65 48 8b 14 25 c0 6b 01 00 <f0> 49 0f b1 14 24 74 08 4c 89 e7 e8 b2 ff ff ff 41 5c 5d c3 66 66
[ 80.505529] RSP: 0018:ffffbdb8424d7c30 EFLAGS: 00010246
[ 80.505559] RAX: 0000000000000000 RBX: ffffa0ff4685b01c RCX: 0000000000000002
[ 80.505583] RDX: ffffa0ff44752b80 RSI: 0000000000000003 RDI: 000000000000000b
[ 80.505610] RBP: ffffbdb8424d7c38 R08: 0000000000000000 R09: 0000000000ffff10
[ 80.505633] R10: 0000000000000006 R11: 000000000000000f R12: 000000000000000b
[ 80.505659] R13: 0000000000000003 R14: 000000000000000b R15: 0000558034938830
[ 80.505683] FS: 00007fc1efb1c580(0000) GS:ffffa0ff4fb00000(0000) knlGS:0000000000000000
[ 80.505709] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 80.505728] CR2: 000000000000000b CR3: 00000004068ea000 CR4: 00000000000006e0
[ 80.505773] Call Trace:
[ 80.505797] blkdev_put+0x21/0xe0
.
.
.
etc etc
oh:
$ uname -r
5.3.0-40-generic
so no matter what I pass to blkdev_put(...) it dies with a NULL pointer. Any idea what stupid simple thing I'm forgetting? kinda pulling my hair out. printk'd the candidate values and they look perfectly sane:
Code:
[0000000022621add]
[00000000381fb7a0]
[000000005b3cda7b]
[000000007dfa3f07]
[00000000a9e07dbf]