All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] accel/qaic: Replace kzalloc + copy_from_user with memdup_user
@ 2025-09-17 12:48 Thorsten Blum
  2025-09-17 12:48 ` [PATCH 2/2] accel/qaic: Replace kcalloc + copy_from_user with memdup_array_user Thorsten Blum
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Thorsten Blum @ 2025-09-17 12:48 UTC (permalink / raw)
  To: Jeff Hugo, Carl Vanderlip, Oded Gabbay
  Cc: Thorsten Blum, linux-arm-msm, dri-devel, linux-kernel

Replace kzalloc() followed by copy_from_user() with memdup_user() to
improve and simplify qaic_attach_slice_bo_ioctl().

No functional changes intended.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/accel/qaic/qaic_data.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
index 797289e9d780..202bdca58847 100644
--- a/drivers/accel/qaic/qaic_data.c
+++ b/drivers/accel/qaic/qaic_data.c
@@ -18,6 +18,7 @@
 #include <linux/scatterlist.h>
 #include <linux/spinlock.h>
 #include <linux/srcu.h>
+#include <linux/string.h>
 #include <linux/types.h>
 #include <linux/uaccess.h>
 #include <linux/wait.h>
@@ -984,18 +985,12 @@ int qaic_attach_slice_bo_ioctl(struct drm_device *dev, void *data, struct drm_fi
 
 	user_data = u64_to_user_ptr(args->data);
 
-	slice_ent = kzalloc(arg_size, GFP_KERNEL);
-	if (!slice_ent) {
-		ret = -EINVAL;
+	slice_ent = memdup_user(user_data, arg_size);
+	if (IS_ERR(slice_ent)) {
+		ret = PTR_ERR(slice_ent);
 		goto unlock_dev_srcu;
 	}
 
-	ret = copy_from_user(slice_ent, user_data, arg_size);
-	if (ret) {
-		ret = -EFAULT;
-		goto free_slice_ent;
-	}
-
 	obj = drm_gem_object_lookup(file_priv, args->hdr.handle);
 	if (!obj) {
 		ret = -ENOENT;
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-10-06 20:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 12:48 [PATCH 1/2] accel/qaic: Replace kzalloc + copy_from_user with memdup_user Thorsten Blum
2025-09-17 12:48 ` [PATCH 2/2] accel/qaic: Replace kcalloc + copy_from_user with memdup_array_user Thorsten Blum
2025-10-06 20:12   ` Jeff Hugo
2025-10-06 20:14   ` Jeff Hugo
2025-09-17 12:54 ` [PATCH 1/2] accel/qaic: Replace kzalloc + copy_from_user with memdup_user Karol Wachowski
2025-10-06 20:05 ` Jeff Hugo
2025-10-06 20:14 ` Jeff Hugo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.