]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
accel/qaic: Replace kzalloc + copy_from_user with memdup_user
authorThorsten Blum <thorsten.blum@linux.dev>
Wed, 17 Sep 2025 12:48:04 +0000 (14:48 +0200)
committerJeff Hugo <jeff.hugo@oss.qualcomm.com>
Mon, 6 Oct 2025 20:12:45 +0000 (14:12 -0600)
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>
Reviewed-by: Karol Wachowski <karol.wachowski@linux.intel.com>
Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
Signed-off-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250917124805.90395-2-thorsten.blum@linux.dev
drivers/accel/qaic/qaic_data.c

index 797289e9d780647b3d498622707850b5612e7a49..202bdca58847db16db668aebe8180cc395d16e10 100644 (file)
@@ -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;