mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 18:21:24 +02:00
drm/etnaviv: use kzalloc_flex
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>
This commit is contained in:
parent
b70c692207
commit
457fa9132c
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user