* [PATCH] tty: serial: qcom_geni: don't ida_free() the console port line
@ 2026-09-04 7:09 Neil Armstrong
2026-09-04 8:02 ` Konrad Dybcio
2026-09-07 4:37 ` Aniket RANDIVE
0 siblings, 2 replies; 5+ messages in thread
From: Neil Armstrong @ 2026-09-04 7:09 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Viken Dadhaniya
Cc: linux-arm-msm, linux-kernel, linux-serial, Neil Armstrong
The console port (qcom_geni_console_port) is a static instance whose
uport.line is hardcoded to 0 and is never allocated from port_ida.
Only the non-console path in get_port_from_line() calls ida_alloc_range().
Fix the qcom_geni_serial_remove() and the matching probe() error path
so unbinding the console device doesn't hit:
WARNING: ida_free called for id=0 which is not allocated
<snip>
qcom_geni_serial_remove+0x58/0x80
Fixes: a53be6945f51 ("serial: qcom-geni: Remove alias dependency from qcom serial driver")
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
drivers/tty/serial/qcom_geni_serial.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 3633723acef8..bdbdfd7dfaac 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -1979,7 +1979,8 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
port->wakeup_irq);
if (ret) {
device_init_wakeup(&pdev->dev, false);
- ida_free(&port_ida, uport->line);
+ if (!uart_console(uport))
+ ida_free(&port_ida, uport->line);
goto error;
}
}
@@ -2024,7 +2025,8 @@ static void qcom_geni_serial_remove(struct platform_device *pdev)
irq_work_sync(&port->tx_kick);
dev_pm_clear_wake_irq(&pdev->dev);
device_init_wakeup(&pdev->dev, false);
- ida_free(&port_ida, uport->line);
+ if (!uart_console(uport))
+ ida_free(&port_ida, uport->line);
uart_remove_one_port(drv, &port->uport);
if (port->rx_dma_addr) {
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260904-topic-sm8x50-upstream-tty-serial-geni-fix-ida-free-4a199c25fd84
Best regards,
--
Neil Armstrong <neil.armstrong@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tty: serial: qcom_geni: don't ida_free() the console port line
2026-09-04 7:09 [PATCH] tty: serial: qcom_geni: don't ida_free() the console port line Neil Armstrong
@ 2026-09-04 8:02 ` Konrad Dybcio
2026-09-04 8:03 ` Konrad Dybcio
2026-09-07 4:37 ` Aniket RANDIVE
1 sibling, 1 reply; 5+ messages in thread
From: Konrad Dybcio @ 2026-09-04 8:02 UTC (permalink / raw)
To: Neil Armstrong, Greg Kroah-Hartman, Jiri Slaby, Viken Dadhaniya
Cc: linux-arm-msm, linux-kernel, linux-serial
On 9/4/26 9:09 AM, Neil Armstrong wrote:
> The console port (qcom_geni_console_port) is a static instance whose
> uport.line is hardcoded to 0 and is never allocated from port_ida.
> Only the non-console path in get_port_from_line() calls ida_alloc_range().
>
> Fix the qcom_geni_serial_remove() and the matching probe() error path
> so unbinding the console device doesn't hit:
>
> WARNING: ida_free called for id=0 which is not allocated
> <snip>
> qcom_geni_serial_remove+0x58/0x80
>
> Fixes: a53be6945f51 ("serial: qcom-geni: Remove alias dependency from qcom serial driver")
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
> drivers/tty/serial/qcom_geni_serial.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
> index 3633723acef8..bdbdfd7dfaac 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
> @@ -1979,7 +1979,8 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
> port->wakeup_irq);
> if (ret) {
> device_init_wakeup(&pdev->dev, false);
> - ida_free(&port_ida, uport->line);
> + if (!uart_console(uport))
> + ida_free(&port_ida, uport->line);
GPT points out this will always return false before uart_add_one_port()
is called
Konrad
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tty: serial: qcom_geni: don't ida_free() the console port line
2026-09-04 8:02 ` Konrad Dybcio
@ 2026-09-04 8:03 ` Konrad Dybcio
2026-09-04 8:04 ` Neil Armstrong
0 siblings, 1 reply; 5+ messages in thread
From: Konrad Dybcio @ 2026-09-04 8:03 UTC (permalink / raw)
To: Neil Armstrong, Greg Kroah-Hartman, Jiri Slaby, Viken Dadhaniya
Cc: linux-arm-msm, linux-kernel, linux-serial
On 9/4/26 10:02 AM, Konrad Dybcio wrote:
> On 9/4/26 9:09 AM, Neil Armstrong wrote:
>> The console port (qcom_geni_console_port) is a static instance whose
>> uport.line is hardcoded to 0 and is never allocated from port_ida.
>> Only the non-console path in get_port_from_line() calls ida_alloc_range().
>>
>> Fix the qcom_geni_serial_remove() and the matching probe() error path
>> so unbinding the console device doesn't hit:
>>
>> WARNING: ida_free called for id=0 which is not allocated
>> <snip>
>> qcom_geni_serial_remove+0x58/0x80
>>
>> Fixes: a53be6945f51 ("serial: qcom-geni: Remove alias dependency from qcom serial driver")
>> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
>> ---
>
>
>> drivers/tty/serial/qcom_geni_serial.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
>> index 3633723acef8..bdbdfd7dfaac 100644
>> --- a/drivers/tty/serial/qcom_geni_serial.c
>> +++ b/drivers/tty/serial/qcom_geni_serial.c
>> @@ -1979,7 +1979,8 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
>> port->wakeup_irq);
>> if (ret) {
>> device_init_wakeup(&pdev->dev, false);
>> - ida_free(&port_ida, uport->line);
>> + if (!uart_console(uport))
>> + ida_free(&port_ida, uport->line);
>
> GPT points out this will always return false before uart_add_one_port()
> is called
You can use if (data->console) instead
Konrad
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tty: serial: qcom_geni: don't ida_free() the console port line
2026-09-04 8:03 ` Konrad Dybcio
@ 2026-09-04 8:04 ` Neil Armstrong
0 siblings, 0 replies; 5+ messages in thread
From: Neil Armstrong @ 2026-09-04 8:04 UTC (permalink / raw)
To: Konrad Dybcio, Greg Kroah-Hartman, Jiri Slaby, Viken Dadhaniya
Cc: linux-arm-msm, linux-kernel, linux-serial
On 9/4/26 10:03, Konrad Dybcio wrote:
> On 9/4/26 10:02 AM, Konrad Dybcio wrote:
>> On 9/4/26 9:09 AM, Neil Armstrong wrote:
>>> The console port (qcom_geni_console_port) is a static instance whose
>>> uport.line is hardcoded to 0 and is never allocated from port_ida.
>>> Only the non-console path in get_port_from_line() calls ida_alloc_range().
>>>
>>> Fix the qcom_geni_serial_remove() and the matching probe() error path
>>> so unbinding the console device doesn't hit:
>>>
>>> WARNING: ida_free called for id=0 which is not allocated
>>> <snip>
>>> qcom_geni_serial_remove+0x58/0x80
>>>
>>> Fixes: a53be6945f51 ("serial: qcom-geni: Remove alias dependency from qcom serial driver")
>>> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
>>> ---
>>
>>
>>> drivers/tty/serial/qcom_geni_serial.c | 6 ++++--
>>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
>>> index 3633723acef8..bdbdfd7dfaac 100644
>>> --- a/drivers/tty/serial/qcom_geni_serial.c
>>> +++ b/drivers/tty/serial/qcom_geni_serial.c
>>> @@ -1979,7 +1979,8 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
>>> port->wakeup_irq);
>>> if (ret) {
>>> device_init_wakeup(&pdev->dev, false);
>>> - ida_free(&port_ida, uport->line);
>>> + if (!uart_console(uport))
>>> + ida_free(&port_ida, uport->line);
>>
>> GPT points out this will always return false before uart_add_one_port()
>> is called
>
> You can use if (data->console) instead
Yep will do
Thanks
>
> Konrad
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tty: serial: qcom_geni: don't ida_free() the console port line
2026-09-04 7:09 [PATCH] tty: serial: qcom_geni: don't ida_free() the console port line Neil Armstrong
2026-09-04 8:02 ` Konrad Dybcio
@ 2026-09-07 4:37 ` Aniket RANDIVE
1 sibling, 0 replies; 5+ messages in thread
From: Aniket RANDIVE @ 2026-09-07 4:37 UTC (permalink / raw)
To: Neil Armstrong, Greg Kroah-Hartman, Jiri Slaby, Viken Dadhaniya
Cc: linux-arm-msm, linux-kernel, linux-serial
Hi Neil,
This appears to be already fixed by:
commit ("serial: qcom-geni: Fix port_ida handling for console and probe
errors")
which also fixes additional port_ida leak paths.
On 9/4/2026 12:39 PM, Neil Armstrong wrote:
> The console port (qcom_geni_console_port) is a static instance whose
> uport.line is hardcoded to 0 and is never allocated from port_ida.
> Only the non-console path in get_port_from_line() calls ida_alloc_range().
>
> Fix the qcom_geni_serial_remove() and the matching probe() error path
> so unbinding the console device doesn't hit:
>
> WARNING: ida_free called for id=0 which is not allocated
> <snip>
> qcom_geni_serial_remove+0x58/0x80
>
> Fixes: a53be6945f51 ("serial: qcom-geni: Remove alias dependency from qcom serial driver")
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
> drivers/tty/serial/qcom_geni_serial.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
> index 3633723acef8..bdbdfd7dfaac 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
> @@ -1979,7 +1979,8 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
> port->wakeup_irq);
> if (ret) {
> device_init_wakeup(&pdev->dev, false);
> - ida_free(&port_ida, uport->line);
> + if (!uart_console(uport))
> + ida_free(&port_ida, uport->line);
> goto error;
> }
> }
> @@ -2024,7 +2025,8 @@ static void qcom_geni_serial_remove(struct platform_device *pdev)
> irq_work_sync(&port->tx_kick);
> dev_pm_clear_wake_irq(&pdev->dev);
> device_init_wakeup(&pdev->dev, false);
> - ida_free(&port_ida, uport->line);
> + if (!uart_console(uport))
> + ida_free(&port_ida, uport->line);
> uart_remove_one_port(drv, &port->uport);
>
> if (port->rx_dma_addr) {
>
> ---
> base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
> change-id: 20260904-topic-sm8x50-upstream-tty-serial-geni-fix-ida-free-4a199c25fd84
>
> Best regards,
> --
> Neil Armstrong <neil.armstrong@linaro.org>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-07 4:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-04 7:09 [PATCH] tty: serial: qcom_geni: don't ida_free() the console port line Neil Armstrong
2026-09-04 8:02 ` Konrad Dybcio
2026-09-04 8:03 ` Konrad Dybcio
2026-09-04 8:04 ` Neil Armstrong
2026-09-07 4:37 ` Aniket RANDIVE
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®