Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: SOF: sof-client-probes-ipc4: add checks to prevent static analysis warnings

make KCFLAGS='-fanalyzer' sound/soc/sof/ reports several NULL pointer
dereference paths.

sof_ipc4_probe_get_module_info() can return a NULL value, but it's
only tested in the init state. Static analyzers cannot know the probe
state machine and hence flags a potential issue for all calls of that
function.

Squelch these errors by adding the same check consistently.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Yaochun Hung <yc.hung@mediatek.com>
Link: https://lore.kernel.org/r/20230731213748.440285-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Pierre-Louis Bossart and committed by
Mark Brown
390e7066 169e154b

+9
+9
sound/soc/sof/sof-client-probes-ipc4.c
··· 146 146 struct sof_man4_module *mentry = sof_ipc4_probe_get_module_info(cdev); 147 147 struct sof_ipc4_msg msg; 148 148 149 + if (!mentry) 150 + return -ENODEV; 151 + 149 152 msg.primary = mentry->id; 150 153 msg.primary |= SOF_IPC4_MSG_TYPE_SET(SOF_IPC4_MOD_DELETE_INSTANCE); 151 154 msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST); ··· 200 197 struct sof_ipc4_msg msg; 201 198 int i, ret; 202 199 200 + if (!mentry) 201 + return -ENODEV; 202 + 203 203 /* The sof_probe_point_desc and sof_ipc4_probe_point structs 204 204 * are of same size and even the integers are the same in the 205 205 * same order, and similar meaning, but since there is no ··· 252 246 struct sof_ipc4_msg msg; 253 247 u32 *probe_point_ids; 254 248 int i, ret; 249 + 250 + if (!mentry) 251 + return -ENODEV; 255 252 256 253 probe_point_ids = kcalloc(num_buffer_id, sizeof(*probe_point_ids), 257 254 GFP_KERNEL);