Skip to contentSkip to conversation

ACER: Add support for accelerometer sensor

DISCUSSION Dan Carpenter 2 participants 8 messages Jun 27, 2012 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

Hello Marek Vasut,

The patch 6ae3a0876185: "ACER: Add support for accelerometer sensor" from Jun 1, 2012, leads to the following Smatch warning:
drivers/platform/x86/acer-wmi.c:1886 acer_wmi_accel_destroy()
error: don't call input_free_device() after input_unregister_device()

drivers/platform/x86/acer-wmi.c
1883 static void acer_wmi_accel_destroy(void)
1884 {
1885 input_unregister_device(acer_wmi_accel_dev);
1886 input_free_device(acer_wmi_accel_dev);
1887 }

It is a double free.

regards,
dan carpenter

#1 lore raw

Dear Dan Carpenter,

Quoted 7 lines

Hello Marek Vasut,

The patch 6ae3a0876185: "ACER: Add support for accelerometer sensor" from Jun 1, 2012, leads to the following Smatch warning:
drivers/platform/x86/acer-wmi.c:1886 acer_wmi_accel_destroy()
error: don't call input_free_device() after input_unregister_device()

Quoted 8 lines

drivers/platform/x86/acer-wmi.c
1883 static void acer_wmi_accel_destroy(void)
1884 {
1885 input_unregister_device(acer_wmi_accel_dev);
1886 input_free_device(acer_wmi_accel_dev);
1887 }

It is a double free.

I see, understood ... shall I submit subsequent patch?

Quoted 2 lines

regards,
dan carpenter

Best regards,
Marek Vasut

#2 lore raw
Quoted 16 lines · Marek Vasut

Dear Dan Carpenter,

Quoted 14 lines

Hello Marek Vasut,

The patch 6ae3a0876185: "ACER: Add support for accelerometer sensor" from Jun 1, 2012, leads to the following Smatch warning:
drivers/platform/x86/acer-wmi.c:1886 acer_wmi_accel_destroy()
error: don't call input_free_device() after input_unregister_device()

drivers/platform/x86/acer-wmi.c
1883 static void acer_wmi_accel_destroy(void)
1884 {
1885 input_unregister_device(acer_wmi_accel_dev);
1886 input_free_device(acer_wmi_accel_dev);
1887 }

Quoted 4 lines
Quoted 1 line

It is a double free.

I see, understood ... shall I submit subsequent patch?

Yes, please. Could you give me a:

regards,
dan carpenter

#3 lore raw

Dear Dan Carpenter,

Quoted 19 lines · Marek Vasut
Quoted 18 lines

Dear Dan Carpenter,

Quoted 16 lines

Hello Marek Vasut,

The patch 6ae3a0876185: "ACER: Add support for accelerometer sensor" from Jun 1, 2012, leads to the following Smatch warning:
drivers/platform/x86/acer-wmi.c:1886 acer_wmi_accel_destroy()

error: don't call input_free_device() after input_unregister_device()

drivers/platform/x86/acer-wmi.c

  1883  static void acer_wmi_accel_destroy(void)
  1884  {
  1885          input_unregister_device(acer_wmi_accel_dev);
  1886          input_free_device(acer_wmi_accel_dev);
  1887  }
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

It is a double free.

I see, understood ... shall I submit subsequent patch?

Yes, please. Could you give me a:

Looking through input_unregister_device(), that call doesn't free the structure. Actually, many drivers call explicitly kfree() on it.

Where do you see the double_free() ?

Quoted 2 lines

regards,
dan carpenter

Best regards,
Marek Vasut

#4 lore raw
Quoted 25 lines · Marek Vasut

Dear Dan Carpenter,

Quoted 23 lines · Marek Vasut
Quoted 21 lines

Dear Dan Carpenter,

Quoted 10 lines

Hello Marek Vasut,

The patch 6ae3a0876185: "ACER: Add support for accelerometer sensor" from Jun 1, 2012, leads to the following Smatch warning:
drivers/platform/x86/acer-wmi.c:1886 acer_wmi_accel_destroy()

error: don't call input_free_device() after input_unregister_device()

drivers/platform/x86/acer-wmi.c

Quoted 7 lines
  1883  static void acer_wmi_accel_destroy(void)
  1884  {
  1885          input_unregister_device(acer_wmi_accel_dev);
  1886          input_free_device(acer_wmi_accel_dev);
  1887  }

It is a double free.

I see, understood ... shall I submit subsequent patch?

Quoted 9 lines
Quoted 3 lines

Yes, please. Could you give me a:

Looking through input_unregister_device(), that call doesn't free the structure. Actually, many drivers call explicitly kfree() on it.

Where do you see the double_free() ?

It's been a while since I looked at this code...

This is described in the comments for input_unregister_device(). It's a refcounted thing. It is freed when the last reference is dropped.

regards,
dan carpenter

#5 lore raw

Dear Dan Carpenter,

Quoted 34 lines · Marek Vasut
Quoted 33 lines

Dear Dan Carpenter,

Quoted 20 lines · Marek Vasut
Quoted 19 lines

Dear Dan Carpenter,

Quoted 17 lines

Hello Marek Vasut,

The patch 6ae3a0876185: "ACER: Add support for accelerometer sensor" from Jun 1, 2012, leads to the following Smatch warning:
drivers/platform/x86/acer-wmi.c:1886 acer_wmi_accel_destroy()

error: don't call input_free_device() after input_unregister_device()

drivers/platform/x86/acer-wmi.c

  1883  static void acer_wmi_accel_destroy(void)
  1884  {
  1885          input_unregister_device(acer_wmi_accel_dev);
  1886          input_free_device(acer_wmi_accel_dev);
  1887  }
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

It is a double free.

I see, understood ... shall I submit subsequent patch?

Yes, please. Could you give me a:

Looking through input_unregister_device(), that call doesn't free the structure. Actually, many drivers call explicitly kfree() on it.

Quoted 7 lines
Quoted 1 line

Where do you see the double_free() ?

It's been a while since I looked at this code...

This is described in the comments for input_unregister_device(). It's a refcounted thing. It is freed when the last reference is dropped.

So kfree() eg. in here drivers/input/joystick/magellan.c is also wrong?

Quoted 2 lines

regards,
dan carpenter

Best regards,
Marek Vasut

#6 lore raw
Quoted 38 lines · Marek Vasut

Dear Dan Carpenter,

Quoted 36 lines · Marek Vasut
Quoted 34 lines

Dear Dan Carpenter,

Quoted 20 lines · Marek Vasut
Quoted 19 lines

Dear Dan Carpenter,

Quoted 17 lines

Hello Marek Vasut,

The patch 6ae3a0876185: "ACER: Add support for accelerometer sensor" from Jun 1, 2012, leads to the following Smatch warning:
drivers/platform/x86/acer-wmi.c:1886 acer_wmi_accel_destroy()

error: don't call input_free_device() after input_unregister_device()

drivers/platform/x86/acer-wmi.c

  1883  static void acer_wmi_accel_destroy(void)
  1884  {
  1885          input_unregister_device(acer_wmi_accel_dev);
  1886          input_free_device(acer_wmi_accel_dev);
  1887  }
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

It is a double free.

I see, understood ... shall I submit subsequent patch?

Yes, please. Could you give me a:

Looking through input_unregister_device(), that call doesn't free the structure. Actually, many drivers call explicitly kfree() on it.

Where do you see the double_free() ?

Quoted 7 lines
Quoted 5 lines

It's been a while since I looked at this code...

This is described in the comments for input_unregister_device(). It's a refcounted thing. It is freed when the last reference is dropped.

So kfree() eg. in here drivers/input/joystick/magellan.c is also wrong?

You are talking about this:?

	input_unregister_device(magellan->dev);
	kfree(magellan);

The kfree() is fine. It's just the ->dev pointer that you are not allowed to touch again after the unregister.

regards,
dan carpenter

#7 lore raw

Dear Dan Carpenter,

Quoted 48 lines · Marek Vasut
Quoted 39 lines

Dear Dan Carpenter,

Quoted 37 lines · Marek Vasut
Quoted 35 lines

Dear Dan Carpenter,

Quoted 21 lines · Marek Vasut
Quoted 20 lines

Dear Dan Carpenter,

Quoted 18 lines

Hello Marek Vasut,

The patch 6ae3a0876185: "ACER: Add support for accelerometer sensor" from Jun 1, 2012, leads to the following Smatch
warning: drivers/platform/x86/acer-wmi.c:1886 acer_wmi_accel_destroy()

error: don't call input_free_device() after input_unregister_device()

drivers/platform/x86/acer-wmi.c

  1883  static void acer_wmi_accel_destroy(void)
  1884  {
  1885          input_unregister_device(acer_wmi_accel_dev);
  1886          input_free_device(acer_wmi_accel_dev);
  1887  }
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

It is a double free.

I see, understood ... shall I submit subsequent patch?

Yes, please. Could you give me a:

Looking through input_unregister_device(), that call doesn't free the structure. Actually, many drivers call explicitly kfree() on it.

Where do you see the double_free() ?

Quoted 7 lines
Quoted 5 lines

It's been a while since I looked at this code...

This is described in the comments for input_unregister_device(). It's a refcounted thing. It is freed when the last reference is dropped.

So kfree() eg. in here drivers/input/joystick/magellan.c is also wrong?

Quoted 7 lines

You are talking about this:?

	input_unregister_device(magellan->dev);
	kfree(magellan);

The kfree() is fine. It's just the ->dev pointer that you are not allowed to touch again after the unregister.

Ah, now it makes sense. Thanks for explaining :)

Quoted 2 lines

regards,
dan carpenter

Best regards,
Marek Vasut