All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thunderbolt: Fix to check return value of ida_simple_get
@ 2019-03-19 17:21 Aditya Pakki
  0 siblings, 0 replies; 4+ messages in thread
From: Aditya Pakki @ 2019-03-19 17:21 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, linux-kernel

ida_simple_get on failure can return an error. The patch ensures that
the dev_set_name is set on non failure cases.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/thunderbolt/xdomain.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index e27dd8beb94b..bd3633e31359 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -772,7 +772,9 @@ static void enumerate_services(struct tb_xdomain *xd)
 		svc->dev.bus = &tb_bus_type;
 		svc->dev.type = &tb_service_type;
 		svc->dev.parent = &xd->dev;
-		dev_set_name(&svc->dev, "%s.%d", dev_name(&xd->dev), svc->id);
+		if (sv->id >= 0)
+			dev_set_name(&svc->dev, "%s.%d", dev_name(&xd->dev),
+					svc->id);
 
 		if (device_register(&svc->dev)) {
 			put_device(&svc->dev);
-- 
2.17.1


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

* Re: [PATCH] thunderbolt: Fix to check return value of ida_simple_get
  2019-03-19 17:22 Aditya Pakki
  2019-03-20 10:56 ` Mika Westerberg
@ 2019-03-20 12:54 ` Mukesh Ojha
  1 sibling, 0 replies; 4+ messages in thread
From: Mukesh Ojha @ 2019-03-20 12:54 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: kjlu, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, linux-kernel


On 3/19/2019 10:52 PM, Aditya Pakki wrote:
> ida_simple_get on failure can return an error. The patch ensures that
> the dev_set_name is set on non failure cases.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---


We should add check against `ida_simple_get` instead of svc->id >= 0 and 
clean up  svc.

Also, It seems clean up is missing when device_register fails and it is 
leaking svc.

Cheers,
Mukesh


>   drivers/thunderbolt/xdomain.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index e27dd8beb94b..b1768f595259 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -772,7 +772,9 @@ static void enumerate_services(struct tb_xdomain *xd)
>   		svc->dev.bus = &tb_bus_type;
>   		svc->dev.type = &tb_service_type;
>   		svc->dev.parent = &xd->dev;
> -		dev_set_name(&svc->dev, "%s.%d", dev_name(&xd->dev), svc->id);
> +		if (svc->id >= 0)
> +			dev_set_name(&svc->dev, "%s.%d", dev_name(&xd->dev),
> +					svc->id);
>   
>   		if (device_register(&svc->dev)) {
>   			put_device(&svc->dev);

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

* Re: [PATCH] thunderbolt: Fix to check return value of ida_simple_get
  2019-03-19 17:22 Aditya Pakki
@ 2019-03-20 10:56 ` Mika Westerberg
  2019-03-20 12:54 ` Mukesh Ojha
  1 sibling, 0 replies; 4+ messages in thread
From: Mika Westerberg @ 2019-03-20 10:56 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: kjlu, Andreas Noever, Michael Jamet, Yehezkel Bernat, linux-kernel

On Tue, Mar 19, 2019 at 12:22:59PM -0500, Aditya Pakki wrote:
> ida_simple_get on failure can return an error. The patch ensures that
> the dev_set_name is set on non failure cases.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/thunderbolt/xdomain.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
> index e27dd8beb94b..b1768f595259 100644
> --- a/drivers/thunderbolt/xdomain.c
> +++ b/drivers/thunderbolt/xdomain.c
> @@ -772,7 +772,9 @@ static void enumerate_services(struct tb_xdomain *xd)
>  		svc->dev.bus = &tb_bus_type;
>  		svc->dev.type = &tb_service_type;
>  		svc->dev.parent = &xd->dev;
> -		dev_set_name(&svc->dev, "%s.%d", dev_name(&xd->dev), svc->id);
> +		if (svc->id >= 0)
> +			dev_set_name(&svc->dev, "%s.%d", dev_name(&xd->dev),
> +					svc->id);

I think the correct way to handle this case is to cleanup svc right
after the allocation fails and then break out without enumerating more
services.

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

* [PATCH] thunderbolt: Fix to check return value of ida_simple_get
@ 2019-03-19 17:22 Aditya Pakki
  2019-03-20 10:56 ` Mika Westerberg
  2019-03-20 12:54 ` Mukesh Ojha
  0 siblings, 2 replies; 4+ messages in thread
From: Aditya Pakki @ 2019-03-19 17:22 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, Andreas Noever, Michael Jamet, Mika Westerberg,
	Yehezkel Bernat, linux-kernel

ida_simple_get on failure can return an error. The patch ensures that
the dev_set_name is set on non failure cases.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/thunderbolt/xdomain.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index e27dd8beb94b..b1768f595259 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -772,7 +772,9 @@ static void enumerate_services(struct tb_xdomain *xd)
 		svc->dev.bus = &tb_bus_type;
 		svc->dev.type = &tb_service_type;
 		svc->dev.parent = &xd->dev;
-		dev_set_name(&svc->dev, "%s.%d", dev_name(&xd->dev), svc->id);
+		if (svc->id >= 0)
+			dev_set_name(&svc->dev, "%s.%d", dev_name(&xd->dev),
+					svc->id);
 
 		if (device_register(&svc->dev)) {
 			put_device(&svc->dev);
-- 
2.17.1


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

end of thread, other threads:[~2019-03-20 12:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19 17:21 [PATCH] thunderbolt: Fix to check return value of ida_simple_get Aditya Pakki
2019-03-19 17:22 Aditya Pakki
2019-03-20 10:56 ` Mika Westerberg
2019-03-20 12:54 ` Mukesh Ojha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.