summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2010-06-04 16:58:56 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2010-06-04 17:00:57 -0700
commitfa7cca617583eb93a862c5ebbb5a56843210e5a8 (patch)
treecc490347e13c656ad0622ea609e834eb0236fe28
parentb8295f4776912d4c3cef836eb0f158e07b432a25 (diff)
Delay allocation of agp_info so we don't leak it on prior errors
Memory leak of pointer 'agp_info' at line 119 of src/common_capability.c in function 'pci_fill_capabilities_generic'. 'agp_info' allocated at line 107 with calloc(1, 12). 'agp_info' leaks when err != 0 at line 118. at line 124 of src/common_capability.c in function 'pci_fill_capabilities_generic'. 'agp_info' allocated at line 107 with calloc(1, 12). 'agp_info' leaks when err != 0 at line 123. [ This bug was found by the Parfait bug checking tool. For more information see http://research.sun.com/projects/parfait ] Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/common_capability.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/common_capability.c b/src/common_capability.c
index 31d59eb..3963db1 100644
--- a/src/common_capability.c
+++ b/src/common_capability.c
@@ -104,16 +104,11 @@ pci_fill_capabilities_generic( struct pci_device * dev )
switch ( cap_id ) {
case 2: {
- struct pci_agp_info * agp_info = calloc( 1, sizeof( struct pci_agp_info ) );
+ struct pci_agp_info * agp_info;
uint32_t agp_status;
uint8_t agp_ver;
- if ( agp_info == NULL ) {
- return ENOMEM;
- }
-
-
err = pci_device_cfg_read_u8( dev, & agp_ver, cap_offset + 2 );
if ( err ) {
return err;
@@ -124,6 +119,11 @@ pci_fill_capabilities_generic( struct pci_device * dev )
return err;
}
+ agp_info = calloc( 1, sizeof( struct pci_agp_info ) );
+ if ( agp_info == NULL ) {
+ return ENOMEM;
+ }
+
agp_info->config_offset = cap_offset;
agp_info->major_version = (agp_ver & 0x0f0) >> 4;