In the Linux kernel, the following vulnerability has been resolved:
ASoC: soc-compress: prevent the potentially use of null pointer
There is one call trace that sndsocregistercard() ->sndsocbindcard()->socinitpcmruntime() ->sndsocdaicompressnew()->sndsocnewcompress(). In the trace the 'codecdai' transfers from card->dailink, and we can see from the sndsocaddpcmruntime() in sndsocbindcard() that, if value of card->dailink->numcodecs is 0, then 'codecdai' could be null pointer caused by index out of bound in 'asocrtdtocodec(rtd, 0)'. And sndsocregistercard() is called by various platforms. Therefore, it is better to add the check in the case of misusing. And because 'cpudai' has already checked in socinitpcmruntime(), there is no need to check again. Adding the check as follow, then if 'codecdai' is null, sndsocnewcompress() will not pass through the check 'if (playback + capture != 1)', avoiding the leftover use of 'codec_dai'.