From: Thorsten Blum Date: Wed, 17 Sep 2025 12:48:04 +0000 (+0200) Subject: accel/qaic: Replace kzalloc + copy_from_user with memdup_user X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9c815230630cb4e80e78ed3ef40909a71fc92403;p=thirdparty%2Fkernel%2Flinux.git accel/qaic: Replace kzalloc + copy_from_user with memdup_user 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 Reviewed-by: Karol Wachowski Reviewed-by: Jeff Hugo Signed-off-by: Jeff Hugo Link: https://lore.kernel.org/r/20250917124805.90395-2-thorsten.blum@linux.dev --- diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c index 797289e9d7806..202bdca58847d 100644 --- a/drivers/accel/qaic/qaic_data.c +++ b/drivers/accel/qaic/qaic_data.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -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;