[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADnq5_PE-mvW2zwNeHn6prvTQvh-en9E9F7VE-hCS=a8jJWhAQ@mail.gmail.com>
Date: Mon, 20 May 2019 13:41:00 -0400
From: Alex Deucher <alexdeucher@...il.com>
To: xiaolinkui <xiaolinkui@...inos.cn>
Cc: "Deucher, Alexander" <alexander.deucher@....com>,
Christian Koenig <christian.koenig@....com>,
Chunming Zhou <David1.Zhou@....com>,
Dave Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
xinhui pan <xinhui.pan@....com>,
"Quan, Evan" <evan.quan@....com>,
Maling list - DRI developers
<dri-devel@...ts.freedesktop.org>,
amd-gfx list <amd-gfx@...ts.freedesktop.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpu: drm: use struct_size() in kmalloc()
On Fri, May 17, 2019 at 8:43 AM xiaolinkui <xiaolinkui@...inos.cn> wrote:
>
> Use struct_size() helper to keep code simple.
>
> Signed-off-by: xiaolinkui <xiaolinkui@...inos.cn>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
This patch results in the following build error:
DESCEND objtool
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
CC [M] drivers/gpu/drm/amd/amdgpu/amdgpu_ras.o
In file included from ./include/linux/kernel.h:15,
from ./include/linux/list.h:9,
from ./include/linux/wait.h:7,
from ./include/linux/wait_bit.h:8,
from ./include/linux/fs.h:6,
from ./include/linux/debugfs.h:15,
from drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:24:
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c: In function ‘amdgpu_ras_init’:
./include/linux/build_bug.h:16:45: error: negative width in bit-field
‘<anonymous>’
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
^
./include/linux/compiler.h:349:28: note: in expansion of macro
‘BUILD_BUG_ON_ZERO’
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
^~~~~~~~~~~~~~~~~
./include/linux/overflow.h:306:30: note: in expansion of macro ‘__must_be_array’
sizeof(*(p)->member) + __must_be_array((p)->member),\
^~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1556:16: note: in expansion of
macro ‘struct_size’
con = kmalloc(struct_size(con, objs, AMDGPU_RAS_BLOCK_COUNT),
^~~~~~~~~~~
make[4]: *** [scripts/Makefile.build:276:
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:492: drivers/gpu/drm/amd/amdgpu] Error 2
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [scripts/Makefile.build:492: drivers/gpu/drm] Error 2
make[1]: *** [scripts/Makefile.build:492: drivers/gpu] Error 2
make: *** [Makefile:1042: drivers] Error 2
Alex
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> index 22bd21e..4717a64 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> @@ -1375,8 +1375,7 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
> if (con)
> return 0;
>
> - con = kmalloc(sizeof(struct amdgpu_ras) +
> - sizeof(struct ras_manager) * AMDGPU_RAS_BLOCK_COUNT,
> + con = kmalloc(struct_size(con, objs, AMDGPU_RAS_BLOCK_COUNT),
> GFP_KERNEL|__GFP_ZERO);
> if (!con)
> return -ENOMEM;
> --
> 2.7.4
>
>
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@...ts.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Powered by blists - more mailing lists