Hi,

On Tue, Dec 19, 2006 at 06:52:22PM +0100, Rafael J. Wysocki wrote:
> On Tuesday, 19 December 2006 14:37, Stefan Seyfried wrote:
> > Index: s2ram.c

> > +struct pci_dev *find_vga(void)
> > +{
> > +   struct pci_access *pacc;
> > +   struct pci_dev *dev;
> > +   struct pci_dev *result;
> > +
> > +   pacc = pci_alloc();     /* Get the pci_access structure */
> > +   pci_init(pacc);         /* Initialize the PCI library */
> > +   pci_scan_bus(pacc);     /* We want to get the list of devices */
> > +
> > +   for (dev=pacc->devices; dev; dev=dev->next) {
> > +           pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_CLASS);
> > +           if (dev->device_class == 0x300)
> > +                   break;
> > +   }
> > +
> > +   /* save result */
> 
> Assume (dev->device_class != 0x300), which I'm not sure is possible, but
> let's say it is.  Shouldn't we just set result = NULL here?

Yes. Actually even simpler:
        if (!dev)
                result = NULL;
        else {
> 
> > +   result = malloc(sizeof(*dev));
> > +   if (result)
> > +           memcpy(result, dev, sizeof(*dev));

        }
> > +
> > +   pci_cleanup(pacc);
> > +
> > +   return result;
> > +}

Tested by replacing == 0x300 by ==0x4242, segfaults because the returned
result is invalid (it segfaults in save_vga_pci()).

Fixed locally.
-- 
Stefan Seyfried
QA / R&D Team Mobile Devices        |              "Any ideas, John?"
SUSE LINUX Products GmbH, Nürnberg  | "Well, surrounding them's out." 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Suspend-devel mailing list
Suspend-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/suspend-devel

Reply via email to