Skip to content

Commit

Permalink
serial: sprd: Fix a dereference warning
Browse files Browse the repository at this point in the history
We should validate if the 'sup' is NULL or not before freeing DMA
memory, to fix below warning.

"drivers/tty/serial/sprd_serial.c:1141 sprd_remove()
 error: we previously assumed 'sup' could be null (see line 1132)"

Fixes: f4487db ("serial: sprd: Add DMA mode support")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Lanqing Liu <liuhhome@gmail.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/e2bd92691538e95b04a2c2a728f3292e1617018f.1584325957.git.liuhhome@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Lanqing Liu authored and Greg Kroah-Hartman committed Mar 17, 2020
1 parent f1b49d5 commit efc1769
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/tty/serial/sprd_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,14 +1132,13 @@ static int sprd_remove(struct platform_device *dev)
if (sup) {
uart_remove_one_port(&sprd_uart_driver, &sup->port);
sprd_port[sup->port.line] = NULL;
sprd_rx_free_buf(sup);
sprd_ports_num--;
}

if (!sprd_ports_num)
uart_unregister_driver(&sprd_uart_driver);

sprd_rx_free_buf(sup);

return 0;
}

Expand Down

0 comments on commit efc1769

Please sign in to comment.