Bug 44741 - Resource leak in function snd_cs5530_create()
Summary: Resource leak in function snd_cs5530_create()
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-13 13:27 UTC by RUC_Soft_Sec
Modified: 2012-10-23 18:30 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.39
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description RUC_Soft_Sec 2012-07-13 13:27:44 UTC
Function pci_request_regions() reserves I/O and memory resources for PCI, and when the regions are no longer used, pci_release_regions() is called. But in function snd_cs5530_create() pci_release_regions() is not invoked on one executable path when the requested regions are no longer used. The related source codes are as following.

snd_cs5530_create() @@sound/pci/cs5530.c:128
 128        err = pci_request_regions(pci, "CS5530");
 129        if (err < 0) {
 130                kfree(chip); 
 131                pci_disable_device(pci);
 132                return err;
 133        }
 134        chip->pci_base = pci_resource_start(pci, 0);
 135
 136        mem = pci_ioremap_bar(pci, 0);
 137        if (mem == NULL) {
 138                kfree(chip);
 139                pci_disable_device(pci);
 140                return -EBUSY;
 141        }

When the call to pci_request_regions() at line 128 succeeds, and the call to function pci_ioremap_bar() fails at line 136, then the true branch of the conditional statement at line 137 will be executed. On this branch the requested regions by pci_rquest_regions() shall be released. But until the return statement at line 140, there is no call to pci_release_regions().

Is it a real bug or the regions are released at some other place?

Thank you

RUC_Soft_Sec
Comment 1 Florian Mickler 2012-10-15 21:19:22 UTC
A patch referencing this bug report has been merged in Linux v3.7-rc1:

commit 5a798394c85f3bca963505d3be49180416fce132
Author: Takashi Iwai <tiwai@suse.de>
Date:   Thu Aug 30 13:21:00 2012 -0700

    ALSA: cs5530: Fix resource leak in error path

Note You need to log in before you can comment on or make changes to this bug.