]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dma-mapping: benchmark: avoid needless copy_to_user if benchmark fails
authorFedor Pchelkin <pchelkin@ispras.ru>
Sat, 4 May 2024 11:47:02 +0000 (14:47 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Jul 2024 10:51:21 +0000 (12:51 +0200)
[ Upstream commit f7c9ccaadffd13066353332c13d7e9bf73b8f92d ]

If do_map_benchmark() has failed, there is nothing useful to copy back
to userspace.

Suggested-by: Barry Song <21cnbao@gmail.com>
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Acked-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/dma/map_benchmark.c

index f7f3d14fa69a7753fa950bcf96ef40fefddd2638..4950e0b622b1f3af9e985bb67624401193b8b1db 100644 (file)
@@ -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;