Re: statically allocated input_dev

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Tomas Carnecky <tom@...>
Cc: linux-kernel <linux-kernel@...>
Date: Thursday, November 15, 2007 - 11:15 am

On Nov 15, 2007 9:58 AM, Tomas Carnecky <tom@dbservice.com> wrote:

The oops will not happen when you remove the module but later.
Consider you have a process connected to /dev/input/eventX
corresponding to your input device. Opening evdev node pins in memory
(kref is taken) underlying input_dev which in turn pins parent
platform device. This does not increase your module's reference count
so it still can be unloaded. When you unload the module memory
occupied by tyou module is freed and may be reused for something else.

Now the process that had event device opened decides to close it. This
causes krefs dropped from parent input device and platform device
structures. Cleanup routines will run trying to scrub everything
clean, writing either into freed memory, or, even worse, into memory
now occupied by somethign else. BOOM!


Yes.


Make the structures dynamically alloocated and feel safe from any
changes in refcounting between underlying objects.

-- 
Dmitry
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: statically allocated input_dev, Tomas Carnecky, (Thu Nov 15, 10:58 am)
Re: statically allocated input_dev, Dmitry Torokhov, (Thu Nov 15, 11:15 am)