-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sound: avoid potential crash upon naming error #1240
Conversation
In chn_init(), if dsp_unit2name() fails, the code sets ret to EINVAL and jumps to the out2 label, where the b and bs snd_dbuf variables may be destroyed without having been initialized in the first place. Reported by: Coverity Scan CID: 1545029 CID: 1545025 Sponsored by: The FreeBSD Foundation
2a9156b
to
371c4c7
Compare
@@ -1236,6 +1236,8 @@ chn_init(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t cls, | |||
} | |||
|
|||
PCM_UNLOCK(d); | |||
b = NULL; | |||
bs = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we don't just initialize these to null where they are declared above?
LGTM. @bsdimp We could also do that, I guess it's just cleaner to do it the way Pierre did and have all the declarations in the same place. |
Hmmm @khorben it seems that this can also be a problem for this block as well
If you want I can take care of cleaning the whole initialization in |
If dsp_unit2name() fails, we'll get to out2 with b, bs and devinfo uninitialized, which will result in a panic. Reported by: Pierre Pronchery <pierre@freebsdfoundation.org> Reported by: Coverity Scan CID: 1545029, 1545025 Pull-request: #1240 Sponsored by: The FreeBSD Foundation MFC after: 1 day Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D45272
Unlike
So this looks fine to me. |
If dsp_unit2name() fails, we'll get to out2 with b, bs and devinfo uninitialized, which will result in a panic. Reported by: Pierre Pronchery <pierre@freebsdfoundation.org> Reported by: Coverity Scan CID: 1545029, 1545025 Pull-request: #1240 Sponsored by: The FreeBSD Foundation MFC after: 1 day Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D45272 (cherry picked from commit 5d1a5d6)
If dsp_unit2name() fails, we'll get to out2 with b, bs and devinfo uninitialized, which will result in a panic. Reported by: Pierre Pronchery <pierre@freebsdfoundation.org> Reported by: Coverity Scan CID: 1545029, 1545025 Pull-request: freebsd/freebsd-src#1240 Sponsored by: The FreeBSD Foundation MFC after: 1 day
In chn_init(), if dsp_unit2name() fails, the code sets ret to EINVAL and jumps to the out2 label, where the b and bs snd_dbuf variables may be destroyed without having been initialized in the first place.
Reported by: Coverity Scan
CID: 1545029
CID: 1545025
Sponsored by: The FreeBSD Foundation