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: Clean up sof_ipc_flood_dfs_write()

This function doesn't support partial writes so using
simple_write_to_buffer() doesn't really make sense. It's better to
just use copy_from_user().

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://msgid.link/r/a35dded2-392b-4ccb-9dbb-d782ac9b6547@moroto.mountain
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Dan Carpenter and committed by
Mark Brown
2cfa0eea 84ae7d9c

+11 -6
+11 -6
sound/soc/sof/sof-client-ipc-flood-test.c
··· 160 160 unsigned long ipc_count = 0; 161 161 struct dentry *dentry; 162 162 int err; 163 - size_t size; 164 163 char *string; 165 164 int ret; 165 + 166 + if (*ppos != 0) 167 + return -EINVAL; 166 168 167 169 string = kzalloc(count + 1, GFP_KERNEL); 168 170 if (!string) 169 171 return -ENOMEM; 170 172 171 - size = simple_write_to_buffer(string, count, ppos, buffer, count); 173 + if (copy_from_user(string, buffer, count)) { 174 + ret = -EFAULT; 175 + goto out; 176 + } 172 177 173 178 /* 174 179 * write op is only supported for ipc_flood_count or ··· 203 198 /* limit max duration/ipc count for flood test */ 204 199 if (flood_duration_test) { 205 200 if (!ipc_duration_ms) { 206 - ret = size; 201 + ret = count; 207 202 goto out; 208 203 } 209 204 ··· 212 207 ipc_duration_ms = MAX_IPC_FLOOD_DURATION_MS; 213 208 } else { 214 209 if (!ipc_count) { 215 - ret = size; 210 + ret = count; 216 211 goto out; 217 212 } 218 213 ··· 236 231 if (err < 0) 237 232 dev_err_ratelimited(dev, "debugfs write failed to idle %d\n", err); 238 233 239 - /* return size if test is successful */ 234 + /* return count if test is successful */ 240 235 if (ret >= 0) 241 - ret = size; 236 + ret = count; 242 237 out: 243 238 kfree(string); 244 239 return ret;