Page MenuHomeFreeBSD

sound: Do not fail from vchan_destroy() if children list is empty
Needs ReviewPublic

Authored by christos on Mon, Dec 23, 10:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jan 3, 4:20 AM
Unknown Object (File)
Thu, Jan 2, 5:31 AM
Unknown Object (File)
Tue, Dec 31, 6:22 PM
Unknown Object (File)
Thu, Dec 26, 9:20 AM
Unknown Object (File)
Thu, Dec 26, 8:13 AM
Unknown Object (File)
Thu, Dec 26, 4:40 AM
Subscribers

Details

Summary

vchan_destroy() should be able to call chn_kill() regardless of whether
the channel has been added to the children list yet or not. Also remove
the CHN_F_BUSY check. There is no reason we shouldn't execute the code
below if the parent is not busy.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 61400
Build 58284: arc lint + arc unit

Event Timeline

sys/dev/sound/pcm/vchan.c
845

Neither this nor the left diff guarantee us that the vchan we are removing from the list has actually been added. Perhaps it's better to use CHN_REMOVE_SAFE instead?

sys/dev/sound/pcm/vchan.c
845

Do I see that correctly, SLIST_REMOVE() will just happily dereference the terminal NULL pointer of the list, when the element to be removed is not present? Yes, I think CHN_REMOVE_SAFE is a good choice here.

christos added inline comments.
sys/dev/sound/pcm/vchan.c
845

Yes, there is no checking whatsoever.

christos marked an inline comment as done.

Use CHN_REMOVE_SAFE().

sys/dev/sound/pcm/vchan.c
845

This check shouldn't be necessary anymore. But how about an assertion that the channel isn't in use, per CHN_F_BUSY flag?

christos marked an inline comment as done.

Remove CHN_EMPTY check

sys/dev/sound/pcm/vchan.c
845

I agree with removing the check. However, I am actually not sure whether the correct behavior here is to not go through with the deletion if the channel is busy or to just force it.

sys/dev/sound/pcm/vchan.c
845

Sure, at this point we should go through with the deletion. An assertion would just help to catch programming errors where the vchan is not properly closed and shut down first, in debug builds.