Skip to content

Commit 7c3e8d9

Browse files
andy-shevgregkh
authored andcommitted
serial: 8250_exar: Avoid NULL pointer dereference at ->exit()
It's possible that during ->exit() the private_data is NULL, for instance when there was no GPIO device instantiated. Due to this we may not dereference it. Add a respective check. Note, for now ->exit() only makes sense when GPIO device was instantiated, that's why we may use the check for entire function. Fixes: 81171e7 ("serial: 8250_exar: Constify the software nodes") Reported-by: Maxim Levitsky <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Tested-by: Maxim Levitsky <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8124c8a commit 7c3e8d9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/tty/serial/8250/8250_exar.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,11 @@ static void pci_xr17v35x_exit(struct pci_dev *pcidev)
553553
{
554554
struct exar8250 *priv = pci_get_drvdata(pcidev);
555555
struct uart_8250_port *port = serial8250_get_port(priv->line[0]);
556-
struct platform_device *pdev = port->port.private_data;
556+
struct platform_device *pdev;
557+
558+
pdev = port->port.private_data;
559+
if (!pdev)
560+
return;
557561

558562
device_remove_software_node(&pdev->dev);
559563
platform_device_unregister(pdev);

0 commit comments

Comments
 (0)