From: "Ji-Ze Hong (Peter Hong)" <hpeter@gmail.com>
To: gregkh@linuxfoundation.org, jslaby@suse.com, ricardo.ribalda@gmail.com
Cc: alan@linux.intel.com, peter@hurleysoftware.com,
tom_tsai@fintek.com.tw, peter_hong@fintek.com.tw,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
"Ji-Ze Hong (Peter Hong)" <hpeter+linux_kernel@gmail.com>
Subject: [PATCH] serial: 8250_fintek: Fix potential NULL pointer dereference
Date: Tue, 28 Jun 2016 09:46:30 +0800 [thread overview]
Message-ID: <1467078390-2406-1-git-send-email-hpeter+linux_kernel@gmail.com> (raw)
Fix potential NULL pointer dereference on
'commit 4da22f1418cb ("serial: 8250_fintek: fix the mismatched IRQ mode")'
We try to fix IRQ mode mismatch issue and add the following code to
detect IRQ Level or Edge mode.
struct irq_data *irq_data = irq_get_irq_data(uart->port.irq);
bool level_mode = irqd_is_level_type(irq_data);
But *irq_data had not any check and pass to irqd_is_level_type(),
it may lead to potential NULL pointer dereference.
Also modify detecting IRQ mode when fintek chip found.
Suggested-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Ji-Ze Hong (Peter Hong) <hpeter+linux_kernel@gmail.com>
---
drivers/tty/serial/8250/8250_fintek.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_fintek.c b/drivers/tty/serial/8250/8250_fintek.c
index 737b4b3..9119d0c 100644
--- a/drivers/tty/serial/8250/8250_fintek.c
+++ b/drivers/tty/serial/8250/8250_fintek.c
@@ -212,8 +212,8 @@ int fintek_8250_probe(struct uart_8250_port *uart)
{
struct fintek_8250 *pdata;
struct fintek_8250 probe_data;
- struct irq_data *irq_data = irq_get_irq_data(uart->port.irq);
- bool level_mode = irqd_is_level_type(irq_data);
+ struct irq_data *irq_data;
+ bool level_mode = false; /* Default to Edge/High */
if (find_base_port(&probe_data, uart->port.iobase))
return -ENODEV;
@@ -226,5 +226,14 @@ int fintek_8250_probe(struct uart_8250_port *uart)
uart->port.rs485_config = fintek_8250_rs485_config;
uart->port.private_data = pdata;
+ irq_data = irq_get_irq_data(uart->port.irq);
+ if (irq_data) {
+ level_mode = irqd_is_level_type(irq_data);
+ } else {
+ dev_warn(uart->port.dev,
+ "%s: Can't get irq_data, set this port to Edge/High",
+ __func__);
+ }
+
return fintek_8250_set_irq_mode(pdata, level_mode);
}
--
1.9.1
next reply other threads:[~2016-06-28 1:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-28 1:46 Ji-Ze Hong (Peter Hong) [this message]
2016-08-18 16:22 ` Ricardo Ribalda Delgado
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=1467078390-2406-1-git-send-email-hpeter+linux_kernel@gmail.com \
--to=hpeter@gmail.com \
--cc=alan@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpeter+linux_kernel@gmail.com \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=peter@hurleysoftware.com \
--cc=peter_hong@fintek.com.tw \
--cc=ricardo.ribalda@gmail.com \
--cc=tom_tsai@fintek.com.tw \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®