[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YK+UbvNhHBw3H27Z@kroah.com>
Date: Thu, 27 May 2021 14:45:34 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: nizamhaider786@...il.com
Cc: laforge@...monks.org, arnd@...db.de, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] char: pcmcia: cm4000_cs: Fix failure handling
On Tue, May 25, 2021 at 04:32:34AM +0530, nizamhaider786@...il.com wrote:
> From: Nijam Haider <nizamhaider786@...il.com>
>
> Handled failure cases of device_create()
>
> Signed-off-by: Nijam Haider <nizamhaider786@...il.com>
> ---
> V1 -> V2: Added description and changelog
> ---
> drivers/char/pcmcia/cm4000_cs.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
> index 89681f07bc78..1ed4eac6b8ef 100644
> --- a/drivers/char/pcmcia/cm4000_cs.c
> +++ b/drivers/char/pcmcia/cm4000_cs.c
> @@ -1783,6 +1783,7 @@ static int cm4000_probe(struct pcmcia_device *link)
> {
> struct cm4000_dev *dev;
> int i, ret;
> + struct device *dev_ret;
>
> for (i = 0; i < CM4000_MAX_DEV; i++)
> if (dev_table[i] == NULL)
> @@ -1814,8 +1815,14 @@ static int cm4000_probe(struct pcmcia_device *link)
> return ret;
> }
>
> - device_create(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i);
> -
> + dev_ret = device_create(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i);
> + if (IS_ERR(dev_ret)) {
> + dev_err(&link->dev, "device_create failed for %d\n", i);
> + cm4000_release(link);
> + dev_table[i] = NULL;
> + kfree(dev);
> + return -ENODEV;
> + }
As before, make different err_*: labels and jump to them when cleaning
up.
thanks,
greg k-h
Powered by blists - more mailing lists