]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tty: mxs-auart: fix a potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Thu, 14 Mar 2019 07:21:51 +0000 (02:21 -0500)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 13 Aug 2019 11:38:47 +0000 (12:38 +0100)
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 <kjlu@umn.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.16: There is no out_disable_clks label, so goto
 out_free_clk on error]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/tty/serial/mxs-auart.c

index 8f6d6b5a2eeb83c165d0728930ffd668488df8b9..acacce37ec6615e65b08483650caac6d77f8bbb4 100644 (file)
@@ -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;