Changeset 065064e6 in mainline for uspace/drv/bus/usb/usbmid/explore.c


Ignore:
Timestamp:
2011-10-15T12:49:18Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e3f7418
Parents:
7c95d6f5
Message:

usb: Add and use usb_device_data_alloc.

Inspired by ddf_dev_data_alloc and ddf_fun_data_alloc.
Fix possible double free (hid dev and hid fun shared driver_data).

File:
1 edited

Legend:

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

    r7c95d6f5 r065064e6  
    163163        }
    164164
    165         usb_mid_t *usb_mid = malloc(sizeof(usb_mid_t));
     165        usb_mid_t *usb_mid = usb_device_data_alloc(dev, sizeof(usb_mid_t));
    166166        if (!usb_mid) {
    167167                usb_log_error("Failed to create USB MID structure.\n");
     
    173173        if (usb_mid->ctl_fun == NULL) {
    174174                usb_log_error("Failed to create control function.\n");
    175                 free(usb_mid);
    176175                return false;
    177176        }
     
    184183                    str_error(rc));
    185184                ddf_fun_destroy(usb_mid->ctl_fun);
    186                 free(usb_mid);
    187185                return false;
    188186        }
     
    209207                }
    210208        }
    211         dev->driver_data = usb_mid;
    212209
    213210        return true;
Note: See TracChangeset for help on using the changeset viewer.