mhi.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH] bus: mhi: ep: Check dev_set_name() return value
@ 2022-07-08  1:59 Bo Liu
  2022-07-09  6:07 ` Manivannan Sadhasivam
  2022-07-09  6:11 ` Manivannan Sadhasivam
  0 siblings, 2 replies; 3+ messages in thread
From: Bo Liu @ 2022-07-08  1:59 UTC (permalink / raw)
  To: mani, quic_hemantk; +Cc: mhi, linux-arm-msm, linux-kernel, Bo Liu

It's possible that dev_set_name() returns -ENOMEM, catch and handle this.

Signed-off-by: Bo Liu <liubo03@inspur.com>
---
 drivers/bus/mhi/ep/main.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index 40109a79017a..1dc8a3557a46 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -1242,9 +1242,13 @@ static int mhi_ep_create_device(struct mhi_ep_cntrl *mhi_cntrl, u32 ch_id)
 
 	/* Channel name is same for both UL and DL */
 	mhi_dev->name = mhi_chan->name;
-	dev_set_name(&mhi_dev->dev, "%s_%s",
+	ret = dev_set_name(&mhi_dev->dev, "%s_%s",
 		     dev_name(&mhi_cntrl->mhi_dev->dev),
 		     mhi_dev->name);
+	if (ret) {
+		put_device(&mhi_dev->dev);
+		return ret;
+	}
 
 	ret = device_add(&mhi_dev->dev);
 	if (ret)
@@ -1408,7 +1412,10 @@ int mhi_ep_register_controller(struct mhi_ep_cntrl *mhi_cntrl,
 		goto err_free_irq;
 	}
 
-	dev_set_name(&mhi_dev->dev, "mhi_ep%u", mhi_cntrl->index);
+	ret = dev_set_name(&mhi_dev->dev, "mhi_ep%u", mhi_cntrl->index);
+	if (ret)
+		goto err_put_dev;
+
 	mhi_dev->name = dev_name(&mhi_dev->dev);
 	mhi_cntrl->mhi_dev = mhi_dev;
 
-- 
2.27.0


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

* Re: [PATCH] bus: mhi: ep: Check dev_set_name() return value
  2022-07-08  1:59 [PATCH] bus: mhi: ep: Check dev_set_name() return value Bo Liu
@ 2022-07-09  6:07 ` Manivannan Sadhasivam
  2022-07-09  6:11 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2022-07-09  6:07 UTC (permalink / raw)
  To: Bo Liu; +Cc: mani, quic_hemantk, mhi, linux-arm-msm, linux-kernel

On Thu, Jul 07, 2022 at 09:59:48PM -0400, Bo Liu wrote:
> It's possible that dev_set_name() returns -ENOMEM, catch and handle this.
> 
> Signed-off-by: Bo Liu <liubo03@inspur.com>

Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

Thanks,
Mani

> ---
>  drivers/bus/mhi/ep/main.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
> index 40109a79017a..1dc8a3557a46 100644
> --- a/drivers/bus/mhi/ep/main.c
> +++ b/drivers/bus/mhi/ep/main.c
> @@ -1242,9 +1242,13 @@ static int mhi_ep_create_device(struct mhi_ep_cntrl *mhi_cntrl, u32 ch_id)
>  
>  	/* Channel name is same for both UL and DL */
>  	mhi_dev->name = mhi_chan->name;
> -	dev_set_name(&mhi_dev->dev, "%s_%s",
> +	ret = dev_set_name(&mhi_dev->dev, "%s_%s",
>  		     dev_name(&mhi_cntrl->mhi_dev->dev),
>  		     mhi_dev->name);
> +	if (ret) {
> +		put_device(&mhi_dev->dev);
> +		return ret;
> +	}
>  
>  	ret = device_add(&mhi_dev->dev);
>  	if (ret)
> @@ -1408,7 +1412,10 @@ int mhi_ep_register_controller(struct mhi_ep_cntrl *mhi_cntrl,
>  		goto err_free_irq;
>  	}
>  
> -	dev_set_name(&mhi_dev->dev, "mhi_ep%u", mhi_cntrl->index);
> +	ret = dev_set_name(&mhi_dev->dev, "mhi_ep%u", mhi_cntrl->index);
> +	if (ret)
> +		goto err_put_dev;
> +
>  	mhi_dev->name = dev_name(&mhi_dev->dev);
>  	mhi_cntrl->mhi_dev = mhi_dev;
>  
> -- 
> 2.27.0
> 

-- 
மணிவண்ணன் சதாசிவம்

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

* Re: [PATCH] bus: mhi: ep: Check dev_set_name() return value
  2022-07-08  1:59 [PATCH] bus: mhi: ep: Check dev_set_name() return value Bo Liu
  2022-07-09  6:07 ` Manivannan Sadhasivam
@ 2022-07-09  6:11 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2022-07-09  6:11 UTC (permalink / raw)
  To: Bo Liu; +Cc: quic_hemantk, mhi, linux-arm-msm, linux-kernel

On Thu, Jul 07, 2022 at 09:59:48PM -0400, Bo Liu wrote:
> It's possible that dev_set_name() returns -ENOMEM, catch and handle this.
> 
> Signed-off-by: Bo Liu <liubo03@inspur.com>

Applied to mhi-next!

Thanks,
Mani

> ---
>  drivers/bus/mhi/ep/main.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
> index 40109a79017a..1dc8a3557a46 100644
> --- a/drivers/bus/mhi/ep/main.c
> +++ b/drivers/bus/mhi/ep/main.c
> @@ -1242,9 +1242,13 @@ static int mhi_ep_create_device(struct mhi_ep_cntrl *mhi_cntrl, u32 ch_id)
>  
>  	/* Channel name is same for both UL and DL */
>  	mhi_dev->name = mhi_chan->name;
> -	dev_set_name(&mhi_dev->dev, "%s_%s",
> +	ret = dev_set_name(&mhi_dev->dev, "%s_%s",
>  		     dev_name(&mhi_cntrl->mhi_dev->dev),
>  		     mhi_dev->name);
> +	if (ret) {
> +		put_device(&mhi_dev->dev);
> +		return ret;
> +	}
>  
>  	ret = device_add(&mhi_dev->dev);
>  	if (ret)
> @@ -1408,7 +1412,10 @@ int mhi_ep_register_controller(struct mhi_ep_cntrl *mhi_cntrl,
>  		goto err_free_irq;
>  	}
>  
> -	dev_set_name(&mhi_dev->dev, "mhi_ep%u", mhi_cntrl->index);
> +	ret = dev_set_name(&mhi_dev->dev, "mhi_ep%u", mhi_cntrl->index);
> +	if (ret)
> +		goto err_put_dev;
> +
>  	mhi_dev->name = dev_name(&mhi_dev->dev);
>  	mhi_cntrl->mhi_dev = mhi_dev;
>  
> -- 
> 2.27.0
> 

-- 
மணிவண்ணன் சதாசிவம்

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

end of thread, other threads:[~2022-07-09  6:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08  1:59 [PATCH] bus: mhi: ep: Check dev_set_name() return value Bo Liu
2022-07-09  6:07 ` Manivannan Sadhasivam
2022-07-09  6:11 ` Manivannan Sadhasivam

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).