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: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d83114e975
commit
41fda9c4d9
|
@ -827,14 +827,16 @@ static int __devexit max3100_remove(struct spi_device *spi)
|
||||||
|
|
||||||
/* find out the index for the chip we are removing */
|
/* find out the index for the chip we are removing */
|
||||||
for (i = 0; i < MAX_MAX3100; i++)
|
for (i = 0; i < MAX_MAX3100; i++)
|
||||||
if (max3100s[i] == s)
|
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;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
dev_dbg(&spi->dev, "%s: removing port %d\n", __func__, i);
|
WARN_ON(i == MAX_MAX3100);
|
||||||
uart_remove_one_port(&max3100_uart_driver, &max3100s[i]->port);
|
|
||||||
kfree(max3100s[i]);
|
|
||||||
max3100s[i] = NULL;
|
|
||||||
|
|
||||||
/* check if this is the last chip we have */
|
/* check if this is the last chip we have */
|
||||||
for (i = 0; i < MAX_MAX3100; i++)
|
for (i = 0; i < MAX_MAX3100; i++)
|
||||||
if (max3100s[i]) {
|
if (max3100s[i]) {
|
||||||
|
|
Loading…
Reference in New Issue