drm/nouveau: switch over to vmemdup_user()

2023-08-11 Thread Atul Raut
Use vmemdup_user() rather than duplicating its implementation.

This patch fixes the following Coccinelle warning:
./drivers/gpu/drm/nouveau/nouveau_gem.c:630:7-15: WARNING opportunity for 
vmemdup_user

Signed-off-by: Atul Raut 
---
 drivers/gpu/drm/nouveau/nouveau_gem.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
b/drivers/gpu/drm/nouveau/nouveau_gem.c
index ab9062e50977..a244b39df213 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -627,15 +627,10 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size)
 
size *= nmemb;
 
-   mem = kvmalloc(size, GFP_KERNEL);
-   if (!mem)
+   mem = vmemdup_user(userptr, size);
+   if (IS_ERR(mem))
return ERR_PTR(-ENOMEM);
 
-   if (copy_from_user(mem, userptr, size)) {
-   u_free(mem);
-   return ERR_PTR(-EFAULT);
-   }
-
return mem;
 }
 
-- 
2.34.1



[PATCH] fbdev/amifb: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper

2023-07-31 Thread Atul Raut
Replacing zero-length arrays with C99 flexible-array members
because they are deprecated. Use the new DECLARE_FLEX_ARRAY()
auxiliary macro instead of defining a zero-length array.

This fixes warnings such as:
./drivers/video/fbdev/amifb.c:690:6-10: WARNING use flexible-array member 
instead 
(https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

Signed-off-by: Atul Raut 
---
 drivers/video/fbdev/amifb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/amifb.c b/drivers/video/fbdev/amifb.c
index d88265dbebf4..f216b2c702a1 100644
--- a/drivers/video/fbdev/amifb.c
+++ b/drivers/video/fbdev/amifb.c
@@ -687,7 +687,7 @@ struct fb_var_cursorinfo {
__u16 height;
__u16 xspot;
__u16 yspot;
-   __u8 data[1];   /* field with [height][width]*/
+   DECLARE_FLEX_ARRAY(__u8, data); /* field with [height][width]*/
 };
 
 struct fb_cursorstate {
-- 
2.34.1