Skip to contentSkip to conversation

snd_usb_endpoint_free

DISCUSSION Julia Lawall 3 participants 5 messages Jun 25, 2014

lore
Share & tools
lore
#0 lore raw

The function snd_usb_endpoint_free in sound/usb/endpoint.c is defined as follows:

void snd_usb_endpoint_free(struct list_head *head)

{
        struct snd_usb_endpoint *ep;

        ep = list_entry(head, struct snd_usb_endpoint, list);
        release_urbs(ep, 1);
        kfree(ep);
}

I wonder if the final kfree should be list_del? In practice, this function is only used from snd_usb_audio_disconnect in sound/usb/card.c where the entire list is destroyed, but it seems like quite a generic function that someone may someday want to use for just freeing one entry.

julia

#1 lore raw
Quoted 12 lines · Julia Lawall

The function snd_usb_endpoint_free in sound/usb/endpoint.c is defined as follows:

void snd_usb_endpoint_free(struct list_head *head)

{
        struct snd_usb_endpoint *ep;

        ep = list_entry(head, struct snd_usb_endpoint, list);
        release_urbs(ep, 1);
        kfree(ep);
}
Quoted 1 line

I wonder if the final kfree should be list_del? In practice, this

Sorry, the question should be "I wonder if this function should also use list_del", since list_del doesn't subsume kfree.

julia

Quoted 6 lines

function is only used from snd_usb_audio_disconnect in sound/usb/card.c where the entire list is destroyed, but it seems like quite a generic function that someone may someday want to use for just freeing one entry.

julia

#2 lore raw

Hi Julia,

Quoted 13 lines · Julia Lawall
Quoted 12 lines · Julia Lawall

The function snd_usb_endpoint_free in sound/usb/endpoint.c is defined as follows:

void snd_usb_endpoint_free(struct list_head *head)

{
        struct snd_usb_endpoint *ep;

        ep = list_entry(head, struct snd_usb_endpoint, list);
        release_urbs(ep, 1);
        kfree(ep);
}
Quoted 10 lines
Quoted 1 line

I wonder if the final kfree should be list_del? In practice, this

Sorry, the question should be "I wonder if this function should also use list_del", since list_del doesn't subsume kfree.

julia

Quoted 3 lines

function is only used from snd_usb_audio_disconnect in sound/usb/card.c where the entire list is destroyed, but it seems like quite a generic function that someone may someday want to use for just freeing one entry.

Jup, you're right, a list_del() in there wouldn't harm. However, it currently wouldn't buy us anything either, and other functions we call from snd_usb_audio_disconnect() for list members don't kill their own list entry node themselves.

Thanks,
Daniel

#3 lore raw
Quoted 23 lines · Daniel Mack

Hi Julia,

Quoted 20 lines · Julia Lawall
Quoted 12 lines · Julia Lawall

The function snd_usb_endpoint_free in sound/usb/endpoint.c is defined as follows:

void snd_usb_endpoint_free(struct list_head *head)

{
        struct snd_usb_endpoint *ep;

        ep = list_entry(head, struct snd_usb_endpoint, list);
        release_urbs(ep, 1);
        kfree(ep);
}
Quoted 1 line

I wonder if the final kfree should be list_del? In practice, this

Sorry, the question should be "I wonder if this function should also use list_del", since list_del doesn't subsume kfree.

julia

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

function is only used from snd_usb_audio_disconnect in sound/usb/card.c where the entire list is destroyed, but it seems like quite a generic function that someone may someday want to use for just freeing one entry.

Jup, you're right, a list_del() in there wouldn't harm. However, it currently wouldn't buy us anything either, and other functions we call from snd_usb_audio_disconnect() for list members don't kill their own list entry node themselves.

OK, thanks for the clarification.

julia

#4 lore raw
In reply to Daniel Mack

At Wed, 25 Jun 2014 12:13:25 +0200,

Quoted 24 lines · Daniel Mack

Hi Julia,

Quoted 20 lines · Julia Lawall
Quoted 12 lines · Julia Lawall

The function snd_usb_endpoint_free in sound/usb/endpoint.c is defined as follows:

void snd_usb_endpoint_free(struct list_head *head)

{
        struct snd_usb_endpoint *ep;

        ep = list_entry(head, struct snd_usb_endpoint, list);
        release_urbs(ep, 1);
        kfree(ep);
}
Quoted 1 line

I wonder if the final kfree should be list_del? In practice, this

Sorry, the question should be "I wonder if this function should also use list_del", since list_del doesn't subsume kfree.

julia

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

function is only used from snd_usb_audio_disconnect in sound/usb/card.c where the entire list is destroyed, but it seems like quite a generic function that someone may someday want to use for just freeing one entry.

Jup, you're right, a list_del() in there wouldn't harm. However, it currently wouldn't buy us anything either, and other functions we call from snd_usb_audio_disconnect() for list members don't kill their own list entry node themselves.

Yes, it'd be better but the current code works as is, too.

In anyway, I'm going to add a fix later; we're working on a disconnection race fix that involves with this function.

thanks,

Takashi