* [PATCH][next] drm/amdgpu: Fix sizeof() mismatch in bps_bo kmalloc_array creation
@ 2020-11-25 14:18 Colin King
2020-11-25 14:19 ` Christian König
2020-11-25 15:10 ` Chen, Guchun
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2020-11-25 14:18 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Daniel Vetter,
Tao Zhou, Guchun Chen, amd-gfx, dri-devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
An incorrect sizeof() is being used, sizeof((*data)->bps_bo) is not
correct, it should be sizeof(*(*data)->bps_bo). It just so happens
to work because the sizes are the same. Fix it.
Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
Fixes: 5278a159cf35 ("drm/amdgpu: support reserve bad page for virt (v3)")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 2d51b7694d1f..df15d33e3c5c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -283,7 +283,7 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
return -ENOMEM;
bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
- bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
+ bps_bo = kmalloc_array(align_space, sizeof(*(*data)->bps_bo), GFP_KERNEL);
if (!bps || !bps_bo) {
kfree(bps);
--
2.29.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] drm/amdgpu: Fix sizeof() mismatch in bps_bo kmalloc_array creation
2020-11-25 14:18 [PATCH][next] drm/amdgpu: Fix sizeof() mismatch in bps_bo kmalloc_array creation Colin King
@ 2020-11-25 14:19 ` Christian König
2020-11-25 15:10 ` Chen, Guchun
1 sibling, 0 replies; 3+ messages in thread
From: Christian König @ 2020-11-25 14:19 UTC (permalink / raw)
To: Colin King, Alex Deucher, David Airlie, Daniel Vetter, Tao Zhou,
Guchun Chen, amd-gfx, dri-devel
Cc: kernel-janitors, linux-kernel
Am 25.11.20 um 15:18 schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
>
> An incorrect sizeof() is being used, sizeof((*data)->bps_bo) is not
> correct, it should be sizeof(*(*data)->bps_bo). It just so happens
> to work because the sizes are the same. Fix it.
>
> Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
> Fixes: 5278a159cf35 ("drm/amdgpu: support reserve bad page for virt (v3)")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> index 2d51b7694d1f..df15d33e3c5c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
> @@ -283,7 +283,7 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
> return -ENOMEM;
>
> bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
> - bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
> + bps_bo = kmalloc_array(align_space, sizeof(*(*data)->bps_bo), GFP_KERNEL);
>
> if (!bps || !bps_bo) {
> kfree(bps);
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH][next] drm/amdgpu: Fix sizeof() mismatch in bps_bo kmalloc_array creation
2020-11-25 14:18 [PATCH][next] drm/amdgpu: Fix sizeof() mismatch in bps_bo kmalloc_array creation Colin King
2020-11-25 14:19 ` Christian König
@ 2020-11-25 15:10 ` Chen, Guchun
1 sibling, 0 replies; 3+ messages in thread
From: Chen, Guchun @ 2020-11-25 15:10 UTC (permalink / raw)
To: Colin King, Deucher, Alexander, Koenig, Christian, David Airlie,
Daniel Vetter, Zhou1, Tao, amd-gfx, dri-devel
Cc: kernel-janitors, linux-kernel
[AMD Public Use]
Reviewed-by: Guchun Chen <guchun.chen@amd.com>
Regards,
Guchun
-----Original Message-----
From: Colin King <colin.king@canonical.com>
Sent: Wednesday, November 25, 2020 10:18 PM
To: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; David Airlie <airlied@linux.ie>; Daniel Vetter <daniel@ffwll.ch>; Zhou1, Tao <Tao.Zhou1@amd.com>; Chen, Guchun <Guchun.Chen@amd.com>; amd-gfx@lists.freedesktop.org; dri-devel@lists.freedesktop.org
Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: [PATCH][next] drm/amdgpu: Fix sizeof() mismatch in bps_bo kmalloc_array creation
From: Colin Ian King <colin.king@canonical.com>
An incorrect sizeof() is being used, sizeof((*data)->bps_bo) is not correct, it should be sizeof(*(*data)->bps_bo). It just so happens to work because the sizes are the same. Fix it.
Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")
Fixes: 5278a159cf35 ("drm/amdgpu: support reserve bad page for virt (v3)")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index 2d51b7694d1f..df15d33e3c5c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -283,7 +283,7 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
return -ENOMEM;
bps = kmalloc_array(align_space, sizeof((*data)->bps), GFP_KERNEL);
- bps_bo = kmalloc_array(align_space, sizeof((*data)->bps_bo), GFP_KERNEL);
+ bps_bo = kmalloc_array(align_space, sizeof(*(*data)->bps_bo),
+GFP_KERNEL);
if (!bps || !bps_bo) {
kfree(bps);
--
2.29.2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-25 15:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 14:18 [PATCH][next] drm/amdgpu: Fix sizeof() mismatch in bps_bo kmalloc_array creation Colin King
2020-11-25 14:19 ` Christian König
2020-11-25 15:10 ` Chen, Guchun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®