lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri, 29 Jan 2021 14:28:42 -0500
From:   Alex Deucher <alexdeucher@...il.com>
To:     Colin King <colin.king@...onical.com>
Cc:     Alex Deucher <alexander.deucher@....com>,
        Christian König <christian.koenig@....com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>, Leo Liu <leo.liu@....com>,
        amd-gfx list <amd-gfx@...ts.freedesktop.org>,
        Maling list - DRI developers 
        <dri-devel@...ts.freedesktop.org>, kernel-janitors@...r.kernel.org,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH][next] drm/amdgpu: Fix memory leak of object caps on error
 return paths

On Fri, Jan 29, 2021 at 7:08 AM Colin King <colin.king@...onical.com> wrote:
>
> From: Colin Ian King <colin.king@...onical.com>
>
> Currently there are three error return paths that don't kfree object
> caps.  Fix this by performing the allocation of caps after the checks
> and error return paths to avoid the premature allocation and memory
> leaking.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: 555fc7fbb2a2 ("drm/amdgpu: add INFO ioctl support for querying video caps")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>

Applied.  Thanks!

Alex


> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 84b666fcfaf6..730f4ac7487b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -988,10 +988,6 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
>                 struct drm_amdgpu_info_video_caps *caps;
>                 int r;
>
> -               caps = kzalloc(sizeof(*caps), GFP_KERNEL);
> -               if (!caps)
> -                       return -ENOMEM;
> -
>                 switch (info->video_cap.type) {
>                 case AMDGPU_INFO_VIDEO_CAPS_DECODE:
>                         r = amdgpu_asic_query_video_codecs(adev, false, &codecs);
> @@ -1009,6 +1005,11 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
>                                       info->video_cap.type);
>                         return -EINVAL;
>                 }
> +
> +               caps = kzalloc(sizeof(*caps), GFP_KERNEL);
> +               if (!caps)
> +                       return -ENOMEM;
> +
>                 for (i = 0; i < codecs->codec_count; i++) {
>                         int idx = codecs->codec_array[i].codec_type;
>
> --
> 2.29.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@...ts.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ