提交 493a7e0d 编写于 作者: D Dmitry Torokhov

Input: fix input_free_device() implementation

input_free_device can't just call kfree because if input_register_device
fails after successfully registering corresponding class device there
is a chance that someone could get a reference to it. We need to use
input_put_device() to make sure that we don't delete input device until
last reference to it was dropped.
Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
上级 58a343f2
......@@ -995,11 +995,6 @@ static inline void init_input_dev(struct input_dev *dev)
struct input_dev *input_allocate_device(void);
static inline void input_free_device(struct input_dev *dev)
{
kfree(dev);
}
static inline struct input_dev *input_get_device(struct input_dev *dev)
{
return to_input_dev(class_device_get(&dev->cdev));
......@@ -1010,6 +1005,11 @@ static inline void input_put_device(struct input_dev *dev)
class_device_put(&dev->cdev);
}
static inline void input_free_device(struct input_dev *dev)
{
input_put_device(dev);
}
int input_register_device(struct input_dev *);
void input_unregister_device(struct input_dev *);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册