All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Wang Chen <wangchen@cn.fujitsu.com>
Cc: linux-kernel@vger.kernel.org, yinghai@kernel.org, tglx@linutronix.de
Subject: Re: [PATCH -tip] irq: check chip->ack before calling (WAS: irq: remove unneeded desc->chip->ack check)
Date: Mon, 29 Dec 2008 12:23:29 +0100	[thread overview]
Message-ID: <20081229112329.GC5065@elte.hu> (raw)
In-Reply-To: <4958618F.9060001@cn.fujitsu.com>


* Wang Chen <wangchen@cn.fujitsu.com> wrote:

> Ingo Molnar said the following on 2008-12-26 21:27:
> > * Wang Chen <wangchen@cn.fujitsu.com> wrote:
> > 
> >> desc->chip->ack is initialized to ack_bad().
> >> It will not be NULL.
> > 
> > hm, that is only true of no_irq_chip() - is it true of all irq_chip 
> > definitions on all architectures?
> > 
> 
> No, some arch's irq_chip doesn't have ack routine.
> So I was wrong.
> But this enlighten another thought that generic irq layer doesn't know
> whether irq_chip has ack routine on some architectures.
> Upon that, before calling chip->ack, should check it's not NULL.
> 
> Impact: fix theoretic NULL dereference
> 
> Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>

applied to tip/irq/genirq, thanks!

(find below how the final commit message ended up looking like.)

	Ingo

------------------>
>From efdc64f0c792ea744bcc9203f35b908e66d42f41 Mon Sep 17 00:00:00 2001
From: Wang Chen <wangchen@cn.fujitsu.com>
Date: Mon, 29 Dec 2008 13:35:11 +0800
Subject: [PATCH] genirq: check chip->ack before calling

Impact: fix theoretical NULL dereference

The generic irq layer doesn't know whether irq_chip has ack routine on some
architectures or not. Upon that, before calling chip->ack, we should check
that it's not NULL.

Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/irq/chip.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 6eb3c79..0ad02d7 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -290,7 +290,8 @@ static inline void mask_ack_irq(struct irq_desc *desc, int irq)
 		desc->chip->mask_ack(irq);
 	else {
 		desc->chip->mask(irq);
-		desc->chip->ack(irq);
+		if (desc->chip->ack)
+			desc->chip->ack(irq);
 	}
 }
 
@@ -475,7 +476,8 @@ handle_edge_irq(unsigned int irq, struct irq_desc *desc)
 	kstat_incr_irqs_this_cpu(irq, desc);
 
 	/* Start handling the irq */
-	desc->chip->ack(irq);
+	if (desc->chip->ack)
+		desc->chip->ack(irq);
 	desc = irq_remap_to_desc(irq, desc);
 
 	/* Mark the IRQ currently in progress.*/


      reply	other threads:[~2008-12-29 11:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-26  9:13 [PATCH 1/2 -tip] irq: remove unneeded desc->chip->ack check Wang Chen
2008-12-26 13:27 ` Ingo Molnar
2008-12-29  5:35   ` [PATCH -tip] irq: check chip->ack before calling (WAS: irq: remove unneeded desc->chip->ack check) Wang Chen
2008-12-29 11:23     ` Ingo Molnar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081229112329.GC5065@elte.hu \
    --to=mingo@elte.hu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wangchen@cn.fujitsu.com \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.