LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-10-2020, 09:56 AM   #1
jingoro
LQ Newbie
 
Registered: Mar 2020
Posts: 2

Rep: Reputation: Disabled
blkdev_get seems to want a pointer, despite all prototypes to the contrary.


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]

Last edited by jingoro; 03-10-2020 at 10:09 AM.
 
Old 03-10-2020, 10:52 AM   #2
jingoro
LQ Newbie
 
Registered: Mar 2020
Posts: 2

Original Poster
Rep: Reputation: Disabled
read the documentation more carefully- "Pointer to block_device on success, ERR_PTR(-errno) on failure." guess testing for "null" was not a good idea.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] C99: it seems like prototypes double up the work szboardstretcher Programming 7 11-19-2014 02:33 PM
LXer: Quite contrary Somerville: Behind the Ada Lovelace legend LXer Syndicated Linux News 0 10-16-2012 11:30 AM
Why does NMAP report â??Host seems downâ? despite host responding to ping? android-eve Linux - Networking 5 11-21-2011 02:35 PM
The contrary effect taken by using taskset command to set processor affinity sobrier Linux - Kernel 2 07-25-2010 01:59 AM
Question about function prototypes xailer Programming 4 12-15-2003 10:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration