Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41fda9c4 authored by Alan Cox's avatar Alan Cox Committed by Greg Kroah-Hartman
Browse files

tty: serial: max3100: Fix error case



We don't want to free a random address if the entry is wrong, cover
this and WARN if it ever happens.

Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d83114e9
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -827,13 +827,15 @@ static int __devexit max3100_remove(struct spi_device *spi)

	/* find out the index for the chip we are removing */
	for (i = 0; i < MAX_MAX3100; i++)
		if (max3100s[i] == s)
			break;

		if (max3100s[i] == s) {
			dev_dbg(&spi->dev, "%s: removing port %d\n", __func__, i);
			uart_remove_one_port(&max3100_uart_driver, &max3100s[i]->port);
			kfree(max3100s[i]);
			max3100s[i] = NULL;
			break;
		}

	WARN_ON(i == MAX_MAX3100);
	
	/* check if this is the last chip we have */
	for (i = 0; i < MAX_MAX3100; i++)