]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/etnaviv: use kzalloc_flex
authorRosen Penev <rosenp@gmail.com>
Fri, 20 Mar 2026 01:07:57 +0000 (18:07 -0700)
committerChristian Gmeiner <cgmeiner@igalia.com>
Tue, 5 May 2026 10:15:05 +0000 (12:15 +0200)
A local helper was developed previously for struct_size.

kzalloc_flex can be used now.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20260320010757.32158-1-rosenp@gmail.com
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
drivers/gpu/drm/etnaviv/etnaviv_drv.h
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c

index 20dad16fd5542891f24fc584e23bace1631d5ee0..55a9e745604dbc948b7c60c89d49a5b037bebd6b 100644 (file)
@@ -93,18 +93,6 @@ void etnaviv_gem_describe_objects(struct etnaviv_drm_private *priv,
 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
 #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
 
-/*
- * Return the storage size of a structure with a variable length array.
- * The array is nelem elements of elem_size, where the base structure
- * is defined by base.  If the size overflows size_t, return zero.
- */
-static inline size_t size_vstruct(size_t nelem, size_t elem_size, size_t base)
-{
-       if (elem_size && nelem > (SIZE_MAX - base) / elem_size)
-               return 0;
-       return base + nelem * elem_size;
-}
-
 /*
  * Etnaviv timeouts are specified wrt CLOCK_MONOTONIC, not jiffies.
  * We need to calculate the timeout in terms of number of jiffies
index fbf693addd749b6f65f35c1a234fab2fc3f4d012..1a77a09b3377ecb74ae33b7c65323524fd62e3dd 100644 (file)
@@ -32,9 +32,8 @@ static struct etnaviv_gem_submit *submit_create(struct drm_device *dev,
                struct etnaviv_gpu *gpu, size_t nr_bos, size_t nr_pmrs)
 {
        struct etnaviv_gem_submit *submit;
-       size_t sz = size_vstruct(nr_bos, sizeof(submit->bos[0]), sizeof(*submit));
 
-       submit = kzalloc(sz, GFP_KERNEL);
+       submit = kzalloc_flex(*submit, bos, nr_bos);
        if (!submit)
                return NULL;