tty: serial: fsl_lpuart: free IDs allocated by IDA
authorMichael Walle <michael@walle.cc>
Tue, 3 Mar 2020 17:42:59 +0000 (18:42 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Mar 2020 13:10:44 +0000 (14:10 +0100)
commit2b2e71fe657510a6f71aa16ef0309fa6bc20ab3d
treef3bf8423f7de926a03761b20ca3630ac6c1f876d
parent0e28ed6c9df986e937e488ec2a0c35bd4bb2a0af
tty: serial: fsl_lpuart: free IDs allocated by IDA

Since commit 3bc3206e1c0f ("serial: fsl_lpuart: Remove the alias node
dependence") the port line number can also be allocated by IDA, but in
case of an error the ID will no be removed again. More importantly, any
ID will be freed in remove(), even if it wasn't allocated but instead
fetched by of_alias_get_id(). If it was not allocated by IDA there will
be a warning:
  WARN(1, "ida_free called for id=%d which is not allocated.\n", id);

Move the ID allocation more to the end of the probe() so that we still
can use plain return in the first error cases.

Fixes: 3bc3206e1c0f ("serial: fsl_lpuart: Remove the alias node dependence")
Signed-off-by: Michael Walle <michael@walle.cc>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200303174306.6015-3-michael@walle.cc
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/fsl_lpuart.c