lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <AANLkTinYUyHJxO-AY8YYaRHu9nuPdyw4aqYJWKOqrCXv@mail.gmail.com>
Date:	Sun, 26 Sep 2010 22:15:18 +0530
From:	Rahul Ruikar <rahul.ruikar@...il.com>
To:	linux-pcmcia@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc:	Rahul Ruikar <rahul.ruikar@...il.com>
Subject: Re: [PATCH] pcmcia: vrc4173_cardu: Fix error path for
 pci_release_regions and pci_disable_device

somethings missed...  i will resend this patch.

- Rahul Ruikar





On 26 September 2010 22:11, Rahul Ruikar <rahul.ruikar@...il.com> wrote:
> - pci_release_regions called during return error path.
> - pci_disable_device called for cases where earlier it was enabled.
> - code duplication avoided/reduced by adding resource release at goto statements.
>
> Signed-off-by: Rahul Ruikar <rahul.ruikar@...il.com>
> ---
>  drivers/pcmcia/vrc4173_cardu.c |   56 +++++++++++++++++++++++++++-------------
>  1 files changed, 38 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/pcmcia/vrc4173_cardu.c b/drivers/pcmcia/vrc4173_cardu.c
> index 9b3c158..5f43a72 100644
> --- a/drivers/pcmcia/vrc4173_cardu.c
> +++ b/drivers/pcmcia/vrc4173_cardu.c
> @@ -474,43 +474,63 @@ static int __devinit vrc4173_cardu_probe(struct pci_dev *dev,
>                return err;
>
>        start = pci_resource_start(dev, 0);
> -       if (start == 0)
> -               return -ENODEV;
> +       if (start == 0) {
> +               ret = -ENODEV;
> +               goto disable;
> +       }
>
>        len = pci_resource_len(dev, 0);
> -       if (len == 0)
> -               return -ENODEV;
> +       if (len == 0) {
> +               ret = -ENODEV;
> +               goto disable;
> +       }
>
> -       if (((flags = pci_resource_flags(dev, 0)) & IORESOURCE_MEM) == 0)
> -               return -EBUSY;
> +       flags = pci_resource_flags(dev, 0);
> +       if ((flags & IORESOURCE_MEM) == 0) {
> +               ret = -EBUSY;
> +               goto disable;
> +       }
>
> -       if ((err = pci_request_regions(dev, socket->name)) < 0)
> -               return err;
> +       err = pci_request_regions(dev, socket->name);
> +       if (err < 0) {
> +               ret = err;
> +               goto disable;
> +       }
>
>        socket->base = ioremap(start, len);
> -       if (socket->base == NULL)
> -               return -ENODEV;
> +       if (socket->base == NULL) {
> +               ret = -ENODEV;
> +               goto release;
> +       }
>
>        socket->dev = dev;
>
>        socket->pcmcia_socket = pcmcia_register_socket(slot, &cardu_operations, 1);
>        if (socket->pcmcia_socket == NULL) {
> -               iounmap(socket->base);
> -               socket->base = NULL;
> -               return -ENOMEM;
> +               ret =  -ENOMEM;
> +               goto unmap;
>        }
>
>        if (request_irq(dev->irq, cardu_interrupt, IRQF_SHARED, socket->name, socket) < 0) {
> -               pcmcia_unregister_socket(socket->pcmcia_socket);
> -               socket->pcmcia_socket = NULL;
> -               iounmap(socket->base);
> -               socket->base = NULL;
> -               return -EBUSY;
> +               ret = -EBUSY;
> +               goto unregister;
>        }
>
>        printk(KERN_INFO "%s at %#08lx, IRQ %d\n", socket->name, start, dev->irq);
>
>        return 0;
> +
> +unregister:
> +       pcmcia_unregister_socket(socket->pcmcia_socket);
> +       socket->pcmcia_socket = NULL;
> +unmap:
> +       iounmap(socket->base);
> +       socket->base = NULL;
> +release:
> +       pci_release_regions(dev);
> +disable:
> +       pci_disable_device(dev);
> +       return ret;
>  }
>
>  static int __devinit vrc4173_cardu_setup(char *options)
> --
> 1.7.2.3
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ