From: Bjorn Helgaas <bhelgaas@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pci@vger.kernel.org
Subject: [scan-admin@coverity.com: New Defects reported by Coverity Scan for Linux]
Date: Thu, 23 Jan 2014 11:42:46 -0700 [thread overview]
Message-ID: <20140123184246.GA7461@google.com> (raw)
FYI. I think the first two (related to "name") are valid. I haven't
figured out the "msi_attrs" one yet.
I think these are related to 1c51b50c2995 ("PCI/MSI: Export MSI mode using
attributes, not kobjects").
Bjorn
----- Forwarded message from scan-admin@coverity.com -----
Date: Thu, 23 Jan 2014 04:23:21 -0800
From: scan-admin@coverity.com
Subject: New Defects reported by Coverity Scan for Linux
Please find the latest report on new defect(s) introduced to Linux found with Coverity Scan.
...
** CID 1163315: Dereference null return value (NULL_RETURNS)
/drivers/pci/msi.c: 551 in populate_msi_sysfs()
** CID 1163316: Resource leak (RESOURCE_LEAK)
/drivers/pci/msi.c: 550 in populate_msi_sysfs()
** CID 1163317: Resource leak (RESOURCE_LEAK)
/drivers/pci/msi.c: 592 in populate_msi_sysfs()
...
________________________________________________________________________________________________________
*** CID 1163315: Dereference null return value (NULL_RETURNS)
/drivers/pci/msi.c: 551 in populate_msi_sysfs()
545 return -ENOMEM;
546 list_for_each_entry(entry, &pdev->msi_list, list) {
547 char *name = kmalloc(20, GFP_KERNEL);
548 msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL);
549 if (!msi_dev_attr)
550 goto error_attrs;
>>> CID 1163315: Dereference null return value (NULL_RETURNS)
>>> Dereferencing a pointer that might be null "name" when calling "sprintf(char *, char const *, ...)".
551 sprintf(name, "%d", entry->irq);
552 sysfs_attr_init(&msi_dev_attr->attr);
553 msi_dev_attr->attr.name = name;
554 msi_dev_attr->attr.mode = S_IRUGO;
555 msi_dev_attr->show = msi_mode_show;
556 msi_attrs[count] = &msi_dev_attr->attr;
________________________________________________________________________________________________________
*** CID 1163316: Resource leak (RESOURCE_LEAK)
/drivers/pci/msi.c: 550 in populate_msi_sysfs()
544 if (!msi_attrs)
545 return -ENOMEM;
546 list_for_each_entry(entry, &pdev->msi_list, list) {
547 char *name = kmalloc(20, GFP_KERNEL);
548 msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL);
549 if (!msi_dev_attr)
>>> CID 1163316: Resource leak (RESOURCE_LEAK)
>>> Variable "name" going out of scope leaks the storage it points to.
550 goto error_attrs;
551 sprintf(name, "%d", entry->irq);
552 sysfs_attr_init(&msi_dev_attr->attr);
553 msi_dev_attr->attr.name = name;
554 msi_dev_attr->attr.mode = S_IRUGO;
555 msi_dev_attr->show = msi_mode_show;
________________________________________________________________________________________________________
*** CID 1163317: Resource leak (RESOURCE_LEAK)
/drivers/pci/msi.c: 592 in populate_msi_sysfs()
586 msi_dev_attr = container_of(msi_attr, struct device_attribute, attr);
587 kfree(msi_attr->name);
588 kfree(msi_dev_attr);
589 ++count;
590 msi_attr = msi_attrs[count];
591 }
>>> CID 1163317: Resource leak (RESOURCE_LEAK)
>>> Variable "msi_attrs" going out of scope leaks the storage it points to.
592 return ret;
593 }
594
595 /**
596 * msi_capability_init - configure device's MSI capability structure
597 * @dev: pointer to the pci_dev data structure of MSI device function
...
To view the defects in Coverity Scan visit, http://scan.coverity.com/projects/128?tab=Overview
----- End forwarded message -----
next reply other threads:[~2014-01-23 18:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-23 18:42 Bjorn Helgaas [this message]
2014-01-23 19:15 ` [scan-admin@coverity.com: New Defects reported by Coverity Scan for Linux] 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 ` [PATCH] PCI: msi: properly check return value of kmalloc Bjorn Helgaas
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=20140123184246.GA7461@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).