Skip to contentSkip to conversation

unregister_input_polled_device() leads to null pointer deref

DISCUSSION Okash Khawaja 2 participants 3 messages Mar 28, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

I'm writing a i2c device driver. In probe(), among other things I call:

polled_input = input_allocate_polled_device();
input_register_polled_device(polled_input);

Then inside remove(), I extract the instance of input_polled_dev and call

input_unregister_polled_device(polled_input);

This results in kernel error:

"Unable to handle kernel NULL pointer dereference at virtual address 00000474".

It turns out that the input_dev pointer inside input_polled_dev is null which leads to this error. But why is input_dev pointer null? It is not null inside probe() function and I don't release it anywhere.

This is code: http://pastebin.com/JJdepyEG and here is link to the output, along with my log statements: http://pastebin.com/badwSvyy.

Thanks,
Okash

#1 lore raw
Quoted 17 lines · Okash Khawaja

Hi,

I'm writing a i2c device driver. In probe(), among other things I call:

polled_input = input_allocate_polled_device();
input_register_polled_device(polled_input);

Then inside remove(), I extract the instance of input_polled_dev and call

input_unregister_polled_device(polled_input);

This results in kernel error:

"Unable to handle kernel NULL pointer dereference at virtual address 00000474".

Quoted 7 lines

It turns out that the input_dev pointer inside input_polled_dev is null which leads to this error. But why is input_dev pointer null? It is not null inside probe() function and I don't release it anywhere.

This is code: http://pastebin.com/JJdepyEG and here is link to the output, along with my log statements: http://pastebin.com/badwSvyy.

input_free_polled_device(polled_input) is always called in your probe function.

Signature · 1 line
Carlo Caione
#2 lore raw
Quoted 22 lines · Carlo Caione
Quoted 19 lines · Okash Khawaja

Hi,

I'm writing a i2c device driver. In probe(), among other things I call:

polled_input = input_allocate_polled_device();
input_register_polled_device(polled_input);

Then inside remove(), I extract the instance of input_polled_dev and call

input_unregister_polled_device(polled_input);

This results in kernel error:

"Unable to handle kernel NULL pointer dereference at virtual address 00000474".

Quoted 8 lines
Quoted 6 lines

It turns out that the input_dev pointer inside input_polled_dev is null which leads to this error. But why is input_dev pointer null? It is not null inside probe() function and I don't release it anywhere.

This is code: http://pastebin.com/JJdepyEG and here is link to the output, along with my log statements: http://pastebin.com/badwSvyy.

input_free_polled_device(polled_input) is always called in your probe function.

Of course! Thanks very much

Quoted 4 lines
Signature · 2 lines
-- 
Carlo Caione