From: willy@linux.intel.com (Matthew Wilcox)
Subject: [PATCH 1/1] NVMe : Corrected memory freeing.
Date: Wed, 17 Jun 2015 12:24:12 -0400 [thread overview]
Message-ID: <20150617162412.GA1971@linux.intel.com> (raw)
In-Reply-To: <1434557459-4732-1-git-send-email-dheepthi.s@gracelabs.com>
On Wed, Jun 17, 2015@09:40:59PM +0530, Dheepthi K wrote:
> Memory freeing order has been corrected incase of
> allocation failure.
This doesn't fix a bug. kfree(NULL) is a no-op, and 'dev' is allocated
with kzalloc, so the current error path will call kfree(NULL).
> @@ -2947,11 +2947,11 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> dev->entry = kzalloc_node(num_possible_cpus() * sizeof(*dev->entry),
> GFP_KERNEL, node);
> if (!dev->entry)
> - goto free;
> + goto free_dev;
> dev->queues = kzalloc_node((num_possible_cpus() + 1) * sizeof(void *),
> GFP_KERNEL, node);
> if (!dev->queues)
> - goto free;
> + goto free_entry;
>
> INIT_LIST_HEAD(&dev->namespaces);
> dev->reset_workfn = nvme_reset_failed_dev;
> @@ -2987,9 +2987,10 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> nvme_release_instance(dev);
> put_pci:
> pci_dev_put(dev->pci_dev);
> - free:
> kfree(dev->queues);
> + free_entry:
> kfree(dev->entry);
> + free_dev:
> kfree(dev);
> return result;
> }
> --
> 1.7.9.5
next prev parent reply other threads:[~2015-06-17 16:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-17 16:10 [PATCH 1/1] NVMe : Corrected memory freeing Dheepthi K
2015-06-17 16:24 ` Matthew Wilcox [this message]
2015-06-17 16:24 ` 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=20150617162412.GA1971@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox