Changeset 359d96f in mainline


Ignore:
Timestamp:
2011-10-13T21:22:55Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
229629d
Parents:
05a119b
Message:

usbmid: Fix memory leaks.

Location:
uspace/drv/bus/usb/usbmid
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbmid/explore.c

    r05a119b r359d96f  
    174174        rc = ddf_fun_bind(ctl_fun);
    175175        if (rc != EOK) {
     176                ddf_fun_destroy(ctl_fun);
    176177                usb_log_error("Failed to bind control function: %s.\n",
    177178                    str_error(rc));
  • uspace/drv/bus/usb/usbmid/usbmid.c

    r05a119b r359d96f  
    106106            (int) interface_descriptor->interface_number);
    107107        if (rc < 0) {
    108                 goto error_leave;
     108                return ENOMEM;
    109109        }
    110110
    111111        /* Create the device. */
    112112        child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name);
     113        free(child_name);
    113114        if (child == NULL) {
    114                 rc = ENOMEM;
    115                 goto error_leave;
     115                return ENOMEM;
    116116        }
    117117
     
    122122
    123123        rc = usb_device_create_match_ids_from_interface(device_descriptor,
    124             interface_descriptor,
    125             &child->match_ids);
     124            interface_descriptor, &child->match_ids);
    126125        if (rc != EOK) {
    127                 goto error_leave;
     126                ddf_fun_destroy(child);
     127                return rc;
    128128        }
    129129
    130130        rc = ddf_fun_bind(child);
    131131        if (rc != EOK) {
    132                 goto error_leave;
     132                /* This takes care of match_id deallocation as well. */
     133                ddf_fun_destroy(child);
     134                return rc;
    133135        }
    134136
    135137        return EOK;
    136 
    137 error_leave:
    138         if (child != NULL) {
    139                 child->name = NULL;
    140                 /* This takes care of match_id deallocation as well. */
    141                 ddf_fun_destroy(child);
    142         }
    143         if (child_name != NULL) {
    144                 free(child_name);
    145         }
    146 
    147         return rc;
    148138}
    149139
Note: See TracChangeset for help on using the changeset viewer.