Changeset 065064e6 in mainline for uspace/drv/bus/usb/usbhub/usbhub.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/usbhub/usbhub.c

    r7c95d6f5 r065064e6  
    117117        ddf_fun_destroy(hub->hub_fun);
    118118
    119         free(hub);
    120         usb_dev->driver_data = NULL;
    121119        usb_log_info("USB hub driver, stopped and cleaned.\n");
    122120        return EOK;
     
    254252{
    255253        assert(usb_dev);
    256         usb_hub_dev_t *hub_dev = malloc(sizeof(usb_hub_dev_t));
     254        usb_hub_dev_t *hub_dev =
     255            usb_device_data_alloc(usb_dev, sizeof(usb_hub_dev_t));
    257256        if (!hub_dev)
    258257            return NULL;
    259258
    260259        hub_dev->usb_device = usb_dev;
    261 
    262260        hub_dev->ports = NULL;
    263261        hub_dev->port_count = 0;
     
    266264        fibril_mutex_initialize(&hub_dev->pending_ops_mutex);
    267265        fibril_condvar_initialize(&hub_dev->pending_ops_cv);
    268         usb_dev->driver_data = hub_dev;
    269266
    270267        return hub_dev;
Note: See TracChangeset for help on using the changeset viewer.