linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: core: Fix error handling for serial_core_ctrl_device_add()
@ 2023-06-02  6:41 Tony Lindgren
  2023-06-02  6:46 ` Tony Lindgren
  0 siblings, 1 reply; 4+ messages in thread
From: Tony Lindgren @ 2023-06-02  6:41 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko
  Cc: Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness,
	Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra,
	linux-omap, linux-serial, linux-kernel

Checking for NULL is not enough as serial_base_ctrl_add() uses ERR_PTR().

Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/tty/serial/serial_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -3342,7 +3342,7 @@ int serial_core_register_port(struct uart_driver *drv, struct uart_port *port)
 	ctrl_dev = serial_core_ctrl_find(drv, port->dev, port->ctrl_id);
 	if (!ctrl_dev) {
 		new_ctrl_dev = serial_core_ctrl_device_add(port);
-		if (!new_ctrl_dev) {
+		if (IS_ERR_OR_NULL(new_ctrl_dev)) {
 			ret = -ENODEV;
 			goto err_unlock;
 		}
-- 
2.41.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] serial: core: Fix error handling for serial_core_ctrl_device_add()
  2023-06-02  6:41 [PATCH] serial: core: Fix error handling for serial_core_ctrl_device_add() Tony Lindgren
@ 2023-06-02  6:46 ` Tony Lindgren
  2023-06-02  6:48   ` Jiri Slaby
  0 siblings, 1 reply; 4+ messages in thread
From: Tony Lindgren @ 2023-06-02  6:46 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko
  Cc: Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness,
	Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra,
	linux-omap, linux-serial, linux-kernel

* Tony Lindgren <tony@atomide.com> [230602 06:41]:
> Checking for NULL is not enough as serial_base_ctrl_add() uses ERR_PTR().
> 
> Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/tty/serial/serial_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -3342,7 +3342,7 @@ int serial_core_register_port(struct uart_driver *drv, struct uart_port *port)
>  	ctrl_dev = serial_core_ctrl_find(drv, port->dev, port->ctrl_id);
>  	if (!ctrl_dev) {
>  		new_ctrl_dev = serial_core_ctrl_device_add(port);
> -		if (!new_ctrl_dev) {
> +		if (IS_ERR_OR_NULL(new_ctrl_dev)) {
>  			ret = -ENODEV;
>  			goto err_unlock;
>  		}

Hmm actually we should also change to use ret = PTR_ERR(new_ctrl_dev) here
instead of translating all the errors to -ENODEV. Will send out v2 version.

Regards,

Tony

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] serial: core: Fix error handling for serial_core_ctrl_device_add()
  2023-06-02  6:46 ` Tony Lindgren
@ 2023-06-02  6:48   ` Jiri Slaby
  2023-06-02  6:51     ` Tony Lindgren
  0 siblings, 1 reply; 4+ messages in thread
From: Jiri Slaby @ 2023-06-02  6:48 UTC (permalink / raw)
  To: Tony Lindgren, Greg Kroah-Hartman, Andy Shevchenko
  Cc: Andy Shevchenko, Dhruva Gole, Ilpo Järvinen, John Ogness,
	Johan Hovold, Sebastian Andrzej Siewior, Vignesh Raghavendra,
	linux-omap, linux-serial, linux-kernel

On 02. 06. 23, 8:46, Tony Lindgren wrote:
> * Tony Lindgren <tony@atomide.com> [230602 06:41]:
>> Checking for NULL is not enough as serial_base_ctrl_add() uses ERR_PTR().
>>
>> Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
>> Signed-off-by: Tony Lindgren <tony@atomide.com>
>> ---
>>   drivers/tty/serial/serial_core.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
>> --- a/drivers/tty/serial/serial_core.c
>> +++ b/drivers/tty/serial/serial_core.c
>> @@ -3342,7 +3342,7 @@ int serial_core_register_port(struct uart_driver *drv, struct uart_port *port)
>>   	ctrl_dev = serial_core_ctrl_find(drv, port->dev, port->ctrl_id);
>>   	if (!ctrl_dev) {
>>   		new_ctrl_dev = serial_core_ctrl_device_add(port);
>> -		if (!new_ctrl_dev) {
>> +		if (IS_ERR_OR_NULL(new_ctrl_dev)) {
>>   			ret = -ENODEV;
>>   			goto err_unlock;
>>   		}
> 
> Hmm actually we should also change to use ret = PTR_ERR(new_ctrl_dev) here
> instead of translating all the errors to -ENODEV. Will send out v2 version.

Why OR_NULL at all, actually?

-- 
js
suse labs


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] serial: core: Fix error handling for serial_core_ctrl_device_add()
  2023-06-02  6:48   ` Jiri Slaby
@ 2023-06-02  6:51     ` Tony Lindgren
  0 siblings, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2023-06-02  6:51 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Greg Kroah-Hartman, Andy Shevchenko, Andy Shevchenko, Dhruva Gole,
	Ilpo Järvinen, John Ogness, Johan Hovold,
	Sebastian Andrzej Siewior, Vignesh Raghavendra, linux-omap,
	linux-serial, linux-kernel

* Jiri Slaby <jirislaby@kernel.org> [230602 06:48]:
> On 02. 06. 23, 8:46, Tony Lindgren wrote:
> > * Tony Lindgren <tony@atomide.com> [230602 06:41]:
> > > Checking for NULL is not enough as serial_base_ctrl_add() uses ERR_PTR().
> > > 
> > > Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
> > > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > ---
> > >   drivers/tty/serial/serial_core.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> > > --- a/drivers/tty/serial/serial_core.c
> > > +++ b/drivers/tty/serial/serial_core.c
> > > @@ -3342,7 +3342,7 @@ int serial_core_register_port(struct uart_driver *drv, struct uart_port *port)
> > >   	ctrl_dev = serial_core_ctrl_find(drv, port->dev, port->ctrl_id);
> > >   	if (!ctrl_dev) {
> > >   		new_ctrl_dev = serial_core_ctrl_device_add(port);
> > > -		if (!new_ctrl_dev) {
> > > +		if (IS_ERR_OR_NULL(new_ctrl_dev)) {
> > >   			ret = -ENODEV;
> > >   			goto err_unlock;
> > >   		}
> > 
> > Hmm actually we should also change to use ret = PTR_ERR(new_ctrl_dev) here
> > instead of translating all the errors to -ENODEV. Will send out v2 version.
> 
> Why OR_NULL at all, actually?

Yup there should be no need for that thanks.

Regards,

Tony

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-02  6:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-02  6:41 [PATCH] serial: core: Fix error handling for serial_core_ctrl_device_add() Tony Lindgren
2023-06-02  6:46 ` Tony Lindgren
2023-06-02  6:48   ` Jiri Slaby
2023-06-02  6:51     ` Tony Lindgren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).