From: Bjorn Helgaas <bhelgaas@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: msi: properly check return value of kmalloc
Date: Wed, 29 Jan 2014 13:56:40 -0700 [thread overview]
Message-ID: <20140129205640.GA16825@google.com> (raw)
In-Reply-To: <20140123193037.GA2605@kroah.com>
On Thu, Jan 23, 2014 at 11:30:37AM -0800, Greg Kroah-Hartman wrote:
> Coverity reported that I forgot to check the return value of kmalloc
> when creating the MSI attribute name, so fix that up and properly free
> it if there is an error when allocating the msi_dev_attr variable.
>
> Fixes: 1c51b50c2995 ("PCI/MSI: Export MSI mode using attributes, not kobjects")
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Applied to my pci/msi branch, thanks!
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
> index 7a0fec6ce571..39dff3fe57af 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -545,9 +545,15 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
> return -ENOMEM;
> list_for_each_entry(entry, &pdev->msi_list, list) {
> char *name = kmalloc(20, GFP_KERNEL);
> + if (!name)
> + goto error_attrs;
> +
> msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL);
> - if (!msi_dev_attr)
> + if (!msi_dev_attr) {
> + kfree(name);
> goto error_attrs;
> + }
> +
> sprintf(name, "%d", entry->irq);
> sysfs_attr_init(&msi_dev_attr->attr);
> msi_dev_attr->attr.name = name;
next prev parent reply other threads:[~2014-01-29 20:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-23 18:42 [scan-admin@coverity.com: New Defects reported by Coverity Scan for Linux] Bjorn Helgaas
2014-01-23 19:15 ` Greg Kroah-Hartman
2014-01-23 19:30 ` [PATCH] PCI: msi: properly check return value of kmalloc Greg Kroah-Hartman
2014-01-23 20:01 ` [PATCH] PCI: msi: properly free memory on an error path Greg Kroah-Hartman
2014-01-23 20:07 ` Dave Jones
2014-01-29 20:56 ` Bjorn Helgaas
2014-01-29 20:56 ` Bjorn Helgaas [this message]
2014-01-23 19:34 ` [scan-admin@coverity.com: New Defects reported by Coverity Scan for Linux] Greg Kroah-Hartman
2014-01-23 19:46 ` Dave Jones
2014-01-23 19:55 ` Greg Kroah-Hartman
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=20140129205640.GA16825@google.com \
--to=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-pci@vger.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;
as well as URLs for NNTP newsgroup(s).