Changeset e199ab3 in mainline for uspace/lib/usbhost/src/bus.c


Ignore:
Timestamp:
2018-11-27T16:51:11Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c483fca
Parents:
9df0f64
git-author:
Jakub Jermar <jakub@…> (2018-11-22 17:36:48)
git-committer:
Jakub Jermar <jakub@…> (2018-11-27 16:51:11)
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

    r9df0f64 re199ab3  
    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.