From: "Christian König" <christian.koenig@amd.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Alex Deucher <alexander.deucher@amd.com>,
"Pan, Xinhui" <Xinhui.Pan@amd.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/radeon: Avoid open coded arithmetic in memory allocation
Date: Mon, 7 Feb 2022 09:01:48 +0100 [thread overview]
Message-ID: <fc165d83-bad2-2189-ec7d-2c756275d85c@amd.com> (raw)
In-Reply-To: <1f44de96e6a49e912111fb3b664f087328b4c2cd.1644082664.git.christophe.jaillet@wanadoo.fr>
Am 05.02.22 um 18:38 schrieb Christophe JAILLET:
> kmalloc_array()/kcalloc() should be used to avoid potential overflow when
> a multiplication is needed to compute the size of the requested memory.
>
> So turn a kzalloc()+explicit size computation into an equivalent kcalloc().
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/radeon/radeon_atombios.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
> index 28c4413f4dc8..7b9cc7a9f42f 100644
> --- a/drivers/gpu/drm/radeon/radeon_atombios.c
> +++ b/drivers/gpu/drm/radeon/radeon_atombios.c
> @@ -897,13 +897,13 @@ bool radeon_get_atom_connector_info_from_supported_devices_table(struct
> union atom_supported_devices *supported_devices;
> int i, j, max_device;
> struct bios_connector *bios_connectors;
> - size_t bc_size = sizeof(*bios_connectors) * ATOM_MAX_SUPPORTED_DEVICE;
> struct radeon_router router;
>
> router.ddc_valid = false;
> router.cd_valid = false;
>
> - bios_connectors = kzalloc(bc_size, GFP_KERNEL);
> + bios_connectors = kcalloc(ATOM_MAX_SUPPORTED_DEVICE,
> + sizeof(*bios_connectors), GFP_KERNEL);
> if (!bios_connectors)
> return false;
>
prev parent reply other threads:[~2022-02-07 8:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-05 17:38 [PATCH] drm/radeon: Avoid open coded arithmetic in memory allocation Christophe JAILLET
2022-02-07 8:01 ` Christian König [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fc165d83-bad2-2189-ec7d-2c756275d85c@amd.com \
--to=christian.koenig@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox