tty: mxs-auart: fix a potential NULL pointer dereference [Linux 3.16.72]

This Linux kernel change "tty: mxs-auart: fix a potential NULL pointer dereference" is included in the Linux 3.16.72 release. This change is authored by Kangjie Lu <kjlu [at]> on Thu Mar 14 02:21:51 2019 -0500. The commit for this change in Linux stable tree is 9169957 (patch) which is from upstream commit 6734330. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 6734330.

tty: mxs-auart: fix a potential NULL pointer dereference

commit 6734330654dac550f12e932996b868c6d0dcb421 upstream.

In case ioremap fails, the fix returns -ENOMEM to avoid NULL
pointer dereferences.
Multiple places use port.membase.

Signed-off-by: Kangjie Lu <>
Signed-off-by: Greg Kroah-Hartman <>
[bwh: Backported to 3.16: There is no out_disable_clks label, so goto
 out_free_clk on error]
Signed-off-by: Ben Hutchings <>

There are 4 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/tty/serial/mxs-auart.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 8f6d6b5..acacce3 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1075,6 +1075,10 @@ static int mxs_auart_probe(struct platform_device *pdev)

    s->port.mapbase = r->start;
    s->port.membase = ioremap(r->start, resource_size(r));
+   if (!s->port.membase) {
+       ret = -ENOMEM;
+       goto out_free_clk;
+   }
    s->port.ops = &mxs_auart_ops;
    s->port.iotype = UPIO_MEM;
    s->port.fifosize = MXS_AUART_FIFO_SIZE;

Leave a Reply

Your email address will not be published. Required fields are marked *