public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Vinod Koul <vkoul@kernel.org>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	dmaengine@vger.kernel.org
Subject: Re: [PATCH] dmaengine: idxd: Fix the error handling path in idxd_cdev_register()
Date: Thu, 21 Apr 2022 08:34:19 -0700	[thread overview]
Message-ID: <f3261912-dc13-46ed-471f-046ba314365d@intel.com> (raw)
In-Reply-To: <1b5033dcc87b5f2a953c413f0306e883e6114542.1650521591.git.christophe.jaillet@wanadoo.fr>


On 4/20/2022 11:13 PM, Christophe JAILLET wrote:
> If a call to alloc_chrdev_region() fails, the already allocated resources
> are leaking.
>
> Add the needed error handling path to fix the leak.
>
> Fixes: 42d279f9137a ("dmaengine: idxd: add char driver to expose submission portal to userland")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Acked-by: Dave Jiang <dave.jiang@intel.com>

Thanks!

> ---
>   drivers/dma/idxd/cdev.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
> index b9b2b4a4124e..033df43db0ce 100644
> --- a/drivers/dma/idxd/cdev.c
> +++ b/drivers/dma/idxd/cdev.c
> @@ -369,10 +369,16 @@ int idxd_cdev_register(void)
>   		rc = alloc_chrdev_region(&ictx[i].devt, 0, MINORMASK,
>   					 ictx[i].name);
>   		if (rc)
> -			return rc;
> +			goto err_free_chrdev_region;
>   	}
>   
>   	return 0;
> +
> +err_free_chrdev_region:
> +	for (i--; i >= 0; i--)
> +		unregister_chrdev_region(ictx[i].devt, MINORMASK);
> +
> +	return rc;
>   }
>   
>   void idxd_cdev_remove(void)

  reply	other threads:[~2022-04-21 15:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21  6:13 [PATCH] dmaengine: idxd: Fix the error handling path in idxd_cdev_register() Christophe JAILLET
2022-04-21 15:34 ` Dave Jiang [this message]
2022-04-22  6:02 ` 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=f3261912-dc13-46ed-471f-046ba314365d@intel.com \
    --to=dave.jiang@intel.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dmaengine@vger.kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox