From: willy@linux.intel.com (Matthew Wilcox)
Subject: [PATCH] NVMe: Free allocated memory in probe failure
Date: Wed, 1 May 2013 15:49:47 -0400 [thread overview]
Message-ID: <20130501194947.GB6057@linux.intel.com> (raw)
In-Reply-To: <1367435271-15784-4-git-send-email-keith.busch@intel.com>
On Wed, May 01, 2013@01:07:50PM -0600, Keith Busch wrote:
> When initializing in probe fails, free only the allocated memory.
'dev'is allocated using kzalloc, and kfree(NULL) is defined to be a no-op.
So having one 'free' label that frees all the memory is fine.
> dev->entry = kcalloc(num_possible_cpus(), sizeof(*dev->entry),
> GFP_KERNEL);
> if (!dev->entry)
> - goto free;
> + goto free_dev;
> dev->queues = kcalloc(num_possible_cpus() + 1, sizeof(void *),
> GFP_KERNEL);
> if (!dev->queues)
> - goto free;
> + goto free_entry;
>
> if (pci_enable_device_mem(pdev))
> goto free;
> @@ -1781,7 +1781,9 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> pci_release_regions(pdev);
> free:
> kfree(dev->queues);
> + free_entry:
> kfree(dev->entry);
> + free_dev:
> kfree(dev);
next prev parent reply other threads:[~2013-05-01 19:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-01 19:07 [PATCH] NVMe: Fix error clean-up on nvme_alloc_queue Keith Busch
2013-05-01 19:07 ` [PATCH] NVMe: Check for NULL memory in nvme_dev_add Keith Busch
2013-05-01 19:07 ` [PATCH] NVMe: Remove dead code " Keith Busch
2013-05-01 20:30 ` Matthew Wilcox
2013-05-01 19:07 ` [PATCH] NVMe: Free allocated memory in probe failure Keith Busch
2013-05-01 19:49 ` Matthew Wilcox [this message]
2013-05-01 19:07 ` [PATCH] NVMe: Free admin queue on request_irq error Keith Busch
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=20130501194947.GB6057@linux.intel.com \
--to=willy@linux.intel.com \
/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.