Changeset 3aa24ae8 in mainline


Ignore:
Timestamp:
2018-11-22T17:36:48Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Parents:
ca21f1e2
Message:

Fix endpoint reference counting

After commit 498ced1, an endpoint is created with an implicit reference.
Adding an extra reference for creation thus adds a reference that will
never be dropped and the endpoint will be leaked.

This commit removes the extra reference.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/bus.c

    rca21f1e2 r3aa24ae8  
    370370int bus_endpoint_add(device_t *device, const usb_endpoint_descriptors_t *desc, endpoint_t **out_ep)
    371371{
    372         int err;
     372        int err = EINVAL;
    373373        assert(device);
    374374
     
    392392        assert((ep->required_transfer_buffer_policy & ~ep->transfer_buffer_policy) == 0);
    393393
    394         /* Bus reference */
    395         endpoint_add_ref(ep);
    396 
    397394        const size_t idx = bus_endpoint_index(ep->endpoint, ep->direction);
    398395        if (idx >= ARRAY_SIZE(device->endpoints)) {
     
    425422        }
    426423        fibril_mutex_unlock(&device->guard);
    427         if (err) {
    428                 endpoint_del_ref(ep);
    429                 return err;
    430         }
     424        if (err)
     425                goto drop;
    431426
    432427        if (out_ep) {
     
    438433        return EOK;
    439434drop:
    440         /* Bus reference */
    441435        endpoint_del_ref(ep);
    442         return EINVAL;
     436        return err;
    443437}
    444438
Note: See TracChangeset for help on using the changeset viewer.