Re: [PATCH v2 2/4] dma-mapping: benchmark: avoid needless copy_to_user if benchmark fails

From: Robin Murphy
Date: Fri May 10 2024 - 13:53:12 EST


On 2024-05-04 12:47 pm, Fedor Pchelkin wrote:
If do_map_benchmark() has failed, there is nothing useful to copy back
to userspace.

I guess there could be some valid partial data if for instance it failed due to OOM in the middle of running, but the standard tool is still going to ignore that if the ioctl() returns an error, so meh.

Acked-by: Robin Murphy <robin.murphy@xxxxxxx>

Suggested-by: Barry Song <21cnbao@xxxxxxxxx>
Signed-off-by: Fedor Pchelkin <pchelkin@xxxxxxxxx>
---
kernel/dma/map_benchmark.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/kernel/dma/map_benchmark.c b/kernel/dma/map_benchmark.c
index 2478957cf9f8..a6edb1ef98c8 100644
--- a/kernel/dma/map_benchmark.c
+++ b/kernel/dma/map_benchmark.c
@@ -256,6 +256,9 @@ static long map_benchmark_ioctl(struct file *file, unsigned int cmd,
* dma_mask changed by benchmark
*/
dma_set_mask(map->dev, old_dma_mask);
+
+ if (ret)
+ return ret;
break;
default:
return -EINVAL;