Skip to contentSkip to conversation

lis3: Fix Oops with NULL platform data

PATCH Superseded Takashi Iwai 3 participants 6 messages Sep 22, 2010 – Sep 23, 2010 Hardware monitoring

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lis3: Fix Oops with NULL platform data

The recent addition of threaded irq handler causes a NULL dereference when used with hp_accel driver, which has NULL pdata.

---

This should go to 2.6.36 and 2.6.35-stable tree.

 drivers/hwmon/lis3lv02d.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/lis3lv02d.c +4 -2
index 5e15967..1c266ec 100644
@@ -354,7 +354,8 @@ static irqreturn_t lis302dl_interrupt_thread1_8b(int irq, void *data)
 
 	struct lis3lv02d *lis3 = data;
 
-	if ((lis3->pdata->irq_cfg & LIS3_IRQ1_MASK) == LIS3_IRQ1_CLICK)
+	if (lis3->pdata &&
+	    (lis3->pdata->irq_cfg & LIS3_IRQ1_MASK) == LIS3_IRQ1_CLICK)
 		lis302dl_interrupt_handle_click(lis3);
 	else
 		lis302dl_interrupt_handle_ff_wu(lis3);
@@ -367,7 +368,8 @@ static irqreturn_t lis302dl_interrupt_thread2_8b(int irq, void *data)
 
 	struct lis3lv02d *lis3 = data;
 
-	if ((lis3->pdata->irq_cfg & LIS3_IRQ2_MASK) == LIS3_IRQ2_CLICK)
+	if (lis3->pdata &&
+	    (lis3->pdata->irq_cfg & LIS3_IRQ2_MASK) == LIS3_IRQ2_CLICK)
 		lis302dl_interrupt_handle_click(lis3);
 	else
 		lis302dl_interrupt_handle_ff_wu(lis3);
Signature · 1 line
1.7.2.2
Acked-by on v1 1/1
#2 lore raw
In reply to Takashi Iwai

Hi

Quoted 45 lines

-----Original Message-----
From: ext Takashi Iwai [mailto:[email protected]]
Sent: 22 September, 2010 14:34
To: Andrew Morton
Cc: Onkalo Samu.P (Nokia-MS/Tampere); Éric Piel; linux- [email protected]
Subject: [PATCH resent] lis3: Fix Oops with NULL platform data

The recent addition of threaded irq handler causes a NULL dereference when used with hp_accel driver, which has NULL pdata.

---

This should go to 2.6.36 and 2.6.35-stable tree.

drivers/hwmon/lis3lv02d.c | 6 ++++--

1 files changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/lis3lv02d.c +2 -1
index 5e15967..1c266ec 100644
@@ -354,7 +354,8 @@ static irqreturn_t lis302dl_interrupt_thread1_8b(int
 irq, void *data)
 
 	struct lis3lv02d *lis3 = data;
 
-	if ((lis3->pdata->irq_cfg & LIS3_IRQ1_MASK) == LIS3_IRQ1_CLICK)
+	if (lis3->pdata &&
+	    (lis3->pdata->irq_cfg & LIS3_IRQ1_MASK) == LIS3_IRQ1_CLICK)
 		lis302dl_interrupt_handle_click(lis3);
 	else
		lis302dl_interrupt_handle_ff_wu(lis3);
drivers/hwmon/lis3lv02d.c +2 -1
@@ -367,7 +368,8 @@ static irqreturn_t lis302dl_interrupt_thread2_8b(int
 irq, void *data)
 
 	struct lis3lv02d *lis3 = data;
 
-	if ((lis3->pdata->irq_cfg & LIS3_IRQ2_MASK) == LIS3_IRQ2_CLICK)
+	if (lis3->pdata &&
+	    (lis3->pdata->irq_cfg & LIS3_IRQ2_MASK) == LIS3_IRQ2_CLICK)
 		lis302dl_interrupt_handle_click(lis3);
 	else
Quoted 1 line
		lis302dl_interrupt_handle_ff_wu(lis3);

Yes, that will remove the kernel oops definitely, but I'm wondering if this thread should be executed at all if there is no pdata available. Eric, is it so that in laptops interrupts are used for free fall detection and polled input device is for joystick?

Interrupts can (and are used) also for other purposes but in that case some additional configurations are done based on platform data.

With this patch, there are just some additional input event refreshes in top of polled device updates. It should really not matter. So,

-Samu

#3 lore raw

At Wed, 22 Sep 2010 13:56:15 +0200,

Quoted 44 lines · <[email protected]> wrote:

Hi

Quoted 40 lines

-----Original Message-----
From: ext Takashi Iwai [mailto:[email protected]]
Sent: 22 September, 2010 14:34
To: Andrew Morton
Cc: Onkalo Samu.P (Nokia-MS/Tampere); Éric Piel; linux- [email protected]
Subject: [PATCH resent] lis3: Fix Oops with NULL platform data

The recent addition of threaded irq handler causes a NULL dereference when used with hp_accel driver, which has NULL pdata.

---

This should go to 2.6.36 and 2.6.35-stable tree.

drivers/hwmon/lis3lv02d.c | 6 ++++--

1 files changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/lis3lv02d.c +2 -1
index 5e15967..1c266ec 100644
@@ -354,7 +354,8 @@ static irqreturn_t lis302dl_interrupt_thread1_8b(int
 irq, void *data)
 
 	struct lis3lv02d *lis3 = data;
 
-	if ((lis3->pdata->irq_cfg & LIS3_IRQ1_MASK) == LIS3_IRQ1_CLICK)
+	if (lis3->pdata &&
+	    (lis3->pdata->irq_cfg & LIS3_IRQ1_MASK) == LIS3_IRQ1_CLICK)
 		lis302dl_interrupt_handle_click(lis3);
 	else
		lis302dl_interrupt_handle_ff_wu(lis3);
drivers/hwmon/lis3lv02d.c +0 -0
@@ -367,7 +368,8 @@ static irqreturn_t lis302dl_interrupt_thread2_8b(int
 irq, void *data)
 
 	struct lis3lv02d *lis3 = data;
 
Quoted 9 lines
Quoted 6 lines
drivers/hwmon/lis3lv02d.c +2 -1
-	if ((lis3->pdata->irq_cfg & LIS3_IRQ2_MASK) == LIS3_IRQ2_CLICK)
+	if (lis3->pdata &&
+	    (lis3->pdata->irq_cfg & LIS3_IRQ2_MASK) == LIS3_IRQ2_CLICK)
 		lis302dl_interrupt_handle_click(lis3);
 	else
		lis302dl_interrupt_handle_ff_wu(lis3);

Yes, that will remove the kernel oops definitely, but I'm wondering if this thread should be executed at all if there is no pdata available.

We may control the caller of request_threaded_irq(), instead. The revised patch is below. (With this patch, the patch for the new LIS3CD chip must be revised, too.)

Quoted 2 lines

Eric, is it so that in laptops interrupts are used for free fall detection and polled input device is for joystick?

Yes, it's so for HP laptops.

Quoted 9 lines

Interrupts can (and are used) also for other purposes but in that case some additional configurations are done based on platform data.

With this patch, there are just some additional input event refreshes in top of polled device updates. It should really not matter. So,

-Samu

thanks,

Takashi

===

Quoted 1 line

From 0e5bdc7516915e92fe471a77da36ecb75d995c0f Mon Sep 17 00:00:00 2001

From: Takashi Iwai <[email protected]>
Date: Wed, 22 Sep 2010 12:16:04 +0200
Subject: [PATCH] lis3: Fix Oops with NULL platform data

The recent addition of threaded irq handler causes a NULL dereference when used with hp_accel driver, which has NULL pdata.

---
this version avoids the unnecessary thread_irq call instead of checking pdata in the irq handler.

 drivers/hwmon/lis3lv02d.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/lis3lv02d.c +2 -2
index 5e15967..0a24177 100644
@@ -301,7 +301,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *dummy)
 	wake_up_interruptible(&lis3_dev.misc_wait);
 	kill_fasync(&lis3_dev.async_queue, SIGIO, POLL_IN);
 out:
-	if (lis3_dev.whoami == WAI_8B && lis3_dev.idev &&
+	if (lis3_dev.pdata && lis3_dev.whoami == WAI_8B && lis3_dev.idev &&
 	    lis3_dev.idev->input->users)
 		return IRQ_WAKE_THREAD;
 	return IRQ_HANDLED;
@@ -742,7 +742,7 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
 	 * io-apic is not configurable (and generates a warning) but I keep it
 	 * in case of support for other hardware.
 	 */
-	if (dev->whoami == WAI_8B)
+	if (dev->pdata && dev->whoami == WAI_8B)
 		thread_fn = lis302dl_interrupt_thread1_8b;
 	else
 		thread_fn = NULL;
Signature · 1 line
1.7.2.2
#4 lore raw

Added lm-sensors list...

Quoted 133 lines

-----Original Message-----
From: ext Takashi Iwai [mailto:[email protected]]
Sent: 22 September, 2010 16:47
To: Onkalo Samu.P (Nokia-MS/Tampere)
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH resent] lis3: Fix Oops with NULL platform data

At Wed, 22 Sep 2010 13:56:15 +0200,

Quoted 21 lines · <[email protected]> wrote:

Hi

Quoted 17 lines

-----Original Message-----
From: ext Takashi Iwai [mailto:[email protected]]
Sent: 22 September, 2010 14:34
To: Andrew Morton
Cc: Onkalo Samu.P (Nokia-MS/Tampere); Éric Piel; linux- [email protected]
Subject: [PATCH resent] lis3: Fix Oops with NULL platform data

The recent addition of threaded irq handler causes a NULL dereference when used with hp_accel driver, which has NULL pdata.

---

This should go to 2.6.36 and 2.6.35-stable tree.

Quoted 8 lines

drivers/hwmon/lis3lv02d.c static irqreturn_t

Quoted 8 lines

drivers/hwmon/lis3lv02d.c | 6 ++++--

1 files changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/lis3lv02d.c +0 -0
index 5e15967..1c266ec 100644
@@ -354,7 +354,8 @@ static irqreturn_t

lis302dl_interrupt_thread1_8b(int

Quoted 11 lines

drivers/hwmon/lis3lv02d.c static irqreturn_t

Quoted 11 lines
drivers/hwmon/lis3lv02d.c +2 -1
 irq, void *data)
 
 	struct lis3lv02d *lis3 = data;
 
-	if ((lis3->pdata->irq_cfg & LIS3_IRQ1_MASK) = LIS3_IRQ1_CLICK)
+	if (lis3->pdata &&
+	    (lis3->pdata->irq_cfg & LIS3_IRQ1_MASK) = LIS3_IRQ1_CLICK)
 		lis302dl_interrupt_handle_click(lis3);
 	else
		lis302dl_interrupt_handle_ff_wu(lis3);
drivers/hwmon/lis3lv02d.c +0 -0
@@ -367,7 +368,8 @@ static irqreturn_t

lis302dl_interrupt_thread2_8b(int

Quoted 4 lines
Quoted 4 lines
drivers/hwmon/lis3lv02d.c +0 -0
 irq, void *data)
 
 	struct lis3lv02d *lis3 = data;
 
Quoted 9 lines
Quoted 6 lines
drivers/hwmon/lis3lv02d.c +2 -1
-	if ((lis3->pdata->irq_cfg & LIS3_IRQ2_MASK) = LIS3_IRQ2_CLICK)
+	if (lis3->pdata &&
+	    (lis3->pdata->irq_cfg & LIS3_IRQ2_MASK) = LIS3_IRQ2_CLICK)
 		lis302dl_interrupt_handle_click(lis3);
 	else
		lis302dl_interrupt_handle_ff_wu(lis3);

Yes, that will remove the kernel oops definitely, but I'm wondering if this thread should be executed at all if there is no pdata available.

We may control the caller of request_threaded_irq(), instead. The revised patch is below. (With this patch, the patch for the new LIS3CD chip must be revised, too.)

Quoted 1 line

Eric, is it so that in laptops interrupts are used for free fall

detection

Quoted 1 line

and polled input device is for joystick?

Yes, it's so for HP laptops.

Quoted 4 lines

Interrupts can (and are used) also for other purposes but in that case some additional configurations are done based on platform data.

With this patch, there are just some additional input event refreshes

in

Quoted 5 lines

top of polled device updates. It should really not matter. So,

-Samu

thanks,

Takashi

=>From 0e5bdc7516915e92fe471a77da36ecb75d995c0f Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Wed, 22 Sep 2010 12:16:04 +0200
Subject: [PATCH] lis3: Fix Oops with NULL platform data

The recent addition of threaded irq handler causes a NULL dereference when used with hp_accel driver, which has NULL pdata.

---
this version avoids the unnecessary thread_irq call instead of checking pdata in the irq handler.

drivers/hwmon/lis3lv02d.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/lis3lv02d.c +0 -0
index 5e15967..0a24177 100644
@@ -301,7 +301,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void
 *dummy)
 	wake_up_interruptible(&lis3_dev.misc_wait);
 	kill_fasync(&lis3_dev.async_queue, SIGIO, POLL_IN);

out:

drivers/hwmon/lis3lv02d.c +1 -1
-	if (lis3_dev.whoami = WAI_8B && lis3_dev.idev &&
+	if (lis3_dev.pdata && lis3_dev.whoami = WAI_8B && lis3_dev.idev

&&

	    lis3_dev.idev->input->users)
		return IRQ_WAKE_THREAD;
	return IRQ_HANDLED;
drivers/hwmon/lis3lv02d.c +0 -0
@@ -742,7 +742,7 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
 	 * io-apic is not configurable (and generates a warning) but I

keep it

	 * in case of support for other hardware.
	 */
drivers/hwmon/lis3lv02d.c +1 -1
-	if (dev->whoami = WAI_8B)
+	if (dev->pdata && dev->whoami = WAI_8B)
		thread_fn = lis302dl_interrupt_thread1_8b;
	else
		thread_fn = NULL;
Quoted 1 line

--

With hp_accel.c irq-thread is not needed so this is ok from that point of view. On the other hand, wakeup / click flags are not configured without platformdata so there is no need to run irq-thread. If the pdata is not prodived at all there is no need to IRQ thread.

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

Acked-by
#5 lore raw
Quoted 143 lines · On Thu, Sep 23, 2010 at 01:06:22AM -0400, [email protected] wrote:

Added lm-sensors list...

Quoted 133 lines

-----Original Message-----
From: ext Takashi Iwai [mailto:[email protected]]
Sent: 22 September, 2010 16:47
To: Onkalo Samu.P (Nokia-MS/Tampere)
Cc: [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH resent] lis3: Fix Oops with NULL platform data

At Wed, 22 Sep 2010 13:56:15 +0200,

Quoted 21 lines · <[email protected]> wrote:

Hi

Quoted 17 lines

-----Original Message-----
From: ext Takashi Iwai [mailto:[email protected]]
Sent: 22 September, 2010 14:34
To: Andrew Morton
Cc: Onkalo Samu.P (Nokia-MS/Tampere); Éric Piel; linux- [email protected]
Subject: [PATCH resent] lis3: Fix Oops with NULL platform data

The recent addition of threaded irq handler causes a NULL dereference when used with hp_accel driver, which has NULL pdata.

---

This should go to 2.6.36 and 2.6.35-stable tree.

Quoted 8 lines

drivers/hwmon/lis3lv02d.c static irqreturn_t

Quoted 8 lines

drivers/hwmon/lis3lv02d.c | 6 ++++--

1 files changed, 4 insertions(+), 2 deletions(-)
drivers/hwmon/lis3lv02d.c +0 -0
index 5e15967..1c266ec 100644
@@ -354,7 +354,8 @@ static irqreturn_t

lis302dl_interrupt_thread1_8b(int

Quoted 11 lines

drivers/hwmon/lis3lv02d.c static irqreturn_t

Quoted 11 lines
drivers/hwmon/lis3lv02d.c +2 -1
 irq, void *data)
 
 	struct lis3lv02d *lis3 = data;
 
-	if ((lis3->pdata->irq_cfg & LIS3_IRQ1_MASK) = LIS3_IRQ1_CLICK)
+	if (lis3->pdata &&
+	    (lis3->pdata->irq_cfg & LIS3_IRQ1_MASK) = LIS3_IRQ1_CLICK)
 		lis302dl_interrupt_handle_click(lis3);
 	else
		lis302dl_interrupt_handle_ff_wu(lis3);
drivers/hwmon/lis3lv02d.c +0 -0
@@ -367,7 +368,8 @@ static irqreturn_t

lis302dl_interrupt_thread2_8b(int

Quoted 4 lines
Quoted 4 lines
drivers/hwmon/lis3lv02d.c +0 -0
 irq, void *data)
 
 	struct lis3lv02d *lis3 = data;
 
Quoted 9 lines
Quoted 6 lines
drivers/hwmon/lis3lv02d.c +2 -1
-	if ((lis3->pdata->irq_cfg & LIS3_IRQ2_MASK) = LIS3_IRQ2_CLICK)
+	if (lis3->pdata &&
+	    (lis3->pdata->irq_cfg & LIS3_IRQ2_MASK) = LIS3_IRQ2_CLICK)
 		lis302dl_interrupt_handle_click(lis3);
 	else
		lis302dl_interrupt_handle_ff_wu(lis3);

Yes, that will remove the kernel oops definitely, but I'm wondering if this thread should be executed at all if there is no pdata available.

We may control the caller of request_threaded_irq(), instead. The revised patch is below. (With this patch, the patch for the new LIS3CD chip must be revised, too.)

Quoted 1 line

Eric, is it so that in laptops interrupts are used for free fall

detection

Quoted 1 line

and polled input device is for joystick?

Yes, it's so for HP laptops.

Quoted 4 lines

Interrupts can (and are used) also for other purposes but in that case some additional configurations are done based on platform data.

With this patch, there are just some additional input event refreshes

in

Quoted 5 lines

top of polled device updates. It should really not matter. So,

-Samu

thanks,

Takashi

=> >From 0e5bdc7516915e92fe471a77da36ecb75d995c0f Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Wed, 22 Sep 2010 12:16:04 +0200
Subject: [PATCH] lis3: Fix Oops with NULL platform data

The recent addition of threaded irq handler causes a NULL dereference when used with hp_accel driver, which has NULL pdata.

---
this version avoids the unnecessary thread_irq call instead of checking pdata in the irq handler.

drivers/hwmon/lis3lv02d.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/lis3lv02d.c +0 -0
index 5e15967..0a24177 100644
@@ -301,7 +301,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void
 *dummy)
 	wake_up_interruptible(&lis3_dev.misc_wait);
 	kill_fasync(&lis3_dev.async_queue, SIGIO, POLL_IN);

out:

drivers/hwmon/lis3lv02d.c +1 -1
-	if (lis3_dev.whoami = WAI_8B && lis3_dev.idev &&
+	if (lis3_dev.pdata && lis3_dev.whoami = WAI_8B && lis3_dev.idev

&&

	    lis3_dev.idev->input->users)
		return IRQ_WAKE_THREAD;
	return IRQ_HANDLED;
drivers/hwmon/lis3lv02d.c +0 -0
@@ -742,7 +742,7 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
 	 * io-apic is not configurable (and generates a warning) but I

keep it

	 * in case of support for other hardware.
	 */
drivers/hwmon/lis3lv02d.c +1 -1
-	if (dev->whoami = WAI_8B)
+	if (dev->pdata && dev->whoami = WAI_8B)
		thread_fn = lis302dl_interrupt_thread1_8b;
	else
		thread_fn = NULL;
Quoted 1 line

--

With hp_accel.c irq-thread is not needed so this is ok from that point of view. On the other hand, wakeup / click flags are not configured without platformdata so there is no need to run irq-thread. If the pdata is not prodived at all there is no need to IRQ thread.

Quoted 2 lines

Looks ok to me.

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors