All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Dan Carpenter <dan.carpenter@oracle.com>, Vinod Koul <vkoul@kernel.org>
Cc: Dave Jiang <dave.jiang@intel.com>, <dmaengine@vger.kernel.org>,
	<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] dmaengine: fix error codes in channel_register()
Date: Tue, 17 Nov 2020 09:24:41 +0200	[thread overview]
Message-ID: <2be1522e-17a8-7d3d-3fdf-f6e729b7740e@ti.com> (raw)
In-Reply-To: <20201113101631.GE168908@mwanda>

Dan,

On 13/11/2020 12.16, Dan Carpenter wrote:
> The error codes were not set on some of these error paths.
> 
> Also the error handling was more confusing than it needed to be so I
> cleaned it up and shuffled it around a bit.

Nice catch,

Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

fwiw I did a boot test as well.

- Péter

> Fixes: d2fb0a043838 ("dmaengine: break out channel registration")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/dma/dmaengine.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index 7974fa0400d8..962cbb5e5f7f 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -1039,16 +1039,15 @@ static int get_dma_id(struct dma_device *device)
>  static int __dma_async_device_channel_register(struct dma_device *device,
>  					       struct dma_chan *chan)
>  {
> -	int rc = 0;
> +	int rc;
>  
>  	chan->local = alloc_percpu(typeof(*chan->local));
>  	if (!chan->local)
> -		goto err_out;
> +		return -ENOMEM;
>  	chan->dev = kzalloc(sizeof(*chan->dev), GFP_KERNEL);
>  	if (!chan->dev) {
> -		free_percpu(chan->local);
> -		chan->local = NULL;
> -		goto err_out;
> +		rc = -ENOMEM;
> +		goto err_free_local;
>  	}
>  
>  	/*
> @@ -1061,7 +1060,8 @@ static int __dma_async_device_channel_register(struct dma_device *device,
>  	if (chan->chan_id < 0) {
>  		pr_err("%s: unable to alloc ida for chan: %d\n",
>  		       __func__, chan->chan_id);
> -		goto err_out;
> +		rc = chan->chan_id;
> +		goto err_free_dev;
>  	}
>  
>  	chan->dev->device.class = &dma_devclass;
> @@ -1082,9 +1082,10 @@ static int __dma_async_device_channel_register(struct dma_device *device,
>  	mutex_lock(&device->chan_mutex);
>  	ida_free(&device->chan_ida, chan->chan_id);
>  	mutex_unlock(&device->chan_mutex);
> - err_out:
> -	free_percpu(chan->local);
> + err_free_dev:
>  	kfree(chan->dev);
> + err_free_local:
> +	free_percpu(chan->local);
>  	return rc;
>  }
>  
> 


Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

WARNING: multiple messages have this Message-ID (diff)
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Dan Carpenter <dan.carpenter@oracle.com>, Vinod Koul <vkoul@kernel.org>
Cc: Dave Jiang <dave.jiang@intel.com>,
	dmaengine@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] dmaengine: fix error codes in channel_register()
Date: Tue, 17 Nov 2020 07:24:41 +0000	[thread overview]
Message-ID: <2be1522e-17a8-7d3d-3fdf-f6e729b7740e@ti.com> (raw)
In-Reply-To: <20201113101631.GE168908@mwanda>

Dan,

On 13/11/2020 12.16, Dan Carpenter wrote:
> The error codes were not set on some of these error paths.
> 
> Also the error handling was more confusing than it needed to be so I
> cleaned it up and shuffled it around a bit.

Nice catch,

Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

fwiw I did a boot test as well.

- Péter

> Fixes: d2fb0a043838 ("dmaengine: break out channel registration")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/dma/dmaengine.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index 7974fa0400d8..962cbb5e5f7f 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -1039,16 +1039,15 @@ static int get_dma_id(struct dma_device *device)
>  static int __dma_async_device_channel_register(struct dma_device *device,
>  					       struct dma_chan *chan)
>  {
> -	int rc = 0;
> +	int rc;
>  
>  	chan->local = alloc_percpu(typeof(*chan->local));
>  	if (!chan->local)
> -		goto err_out;
> +		return -ENOMEM;
>  	chan->dev = kzalloc(sizeof(*chan->dev), GFP_KERNEL);
>  	if (!chan->dev) {
> -		free_percpu(chan->local);
> -		chan->local = NULL;
> -		goto err_out;
> +		rc = -ENOMEM;
> +		goto err_free_local;
>  	}
>  
>  	/*
> @@ -1061,7 +1060,8 @@ static int __dma_async_device_channel_register(struct dma_device *device,
>  	if (chan->chan_id < 0) {
>  		pr_err("%s: unable to alloc ida for chan: %d\n",
>  		       __func__, chan->chan_id);
> -		goto err_out;
> +		rc = chan->chan_id;
> +		goto err_free_dev;
>  	}
>  
>  	chan->dev->device.class = &dma_devclass;
> @@ -1082,9 +1082,10 @@ static int __dma_async_device_channel_register(struct dma_device *device,
>  	mutex_lock(&device->chan_mutex);
>  	ida_free(&device->chan_ida, chan->chan_id);
>  	mutex_unlock(&device->chan_mutex);
> - err_out:
> -	free_percpu(chan->local);
> + err_free_dev:
>  	kfree(chan->dev);
> + err_free_local:
> +	free_percpu(chan->local);
>  	return rc;
>  }
>  
> 


Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  reply	other threads:[~2020-11-17  7:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13 10:16 [PATCH] dmaengine: fix error codes in channel_register() Dan Carpenter
2020-11-13 10:16 ` Dan Carpenter
2020-11-17  7:24 ` Peter Ujfalusi [this message]
2020-11-17  7:24   ` Peter Ujfalusi
2020-11-18 12:21 ` Vinod Koul
2020-11-18 12:33   ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2be1522e-17a8-7d3d-3fdf-f6e729b7740e@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.