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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220628085533.7b7885fb@collabora.com>
Date:   Tue, 28 Jun 2022 08:55:33 +0200
From:   Boris Brezillon <boris.brezillon@...labora.com>
To:     Yu Liao <liaoyu15@...wei.com>
Cc:     <emma@...olt.net>, <mripard@...nel.org>, <eric@...olt.net>,
        <bbrezillon@...nel.org>, <liwei391@...wei.com>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] drm/vc4: fix dereference before NULL check

On Tue, 28 Jun 2022 14:36:57 +0800
Yu Liao <liaoyu15@...wei.com> wrote:

> The "perfmon" pointer is equal to the return value of idr_find
> which may be NULL, access by vc4_perfmon_get before checking if
> it was NULL. Fix this by dereferencing "perfmon" after "perfmon"
> has been null checked.
> 
> Addresses-Coverity: ("Dereference before null check")
> Fixes: 65101d8c9108 ("drm/vc4: Expose performance counters to userspace")
> Signed-off-by: Yu Liao <liaoyu15@...wei.com>

Reviewed-by: Boris Brezillon <boris.brezillon@...labora.com>

> ---
>  drivers/gpu/drm/vc4/vc4_perfmon.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_perfmon.c b/drivers/gpu/drm/vc4/vc4_perfmon.c
> index c7f5adb6bcf8..ca969b8c7dde 100644
> --- a/drivers/gpu/drm/vc4/vc4_perfmon.c
> +++ b/drivers/gpu/drm/vc4/vc4_perfmon.c
> @@ -17,13 +17,17 @@
>  
>  void vc4_perfmon_get(struct vc4_perfmon *perfmon)
>  {
> -	struct vc4_dev *vc4 = perfmon->dev;
> +	struct vc4_dev *vc4;
> +
> +	if (!perfmon)
> +		return;
> +
> +	vc4 = perfmon->dev;
>  
>  	if (WARN_ON_ONCE(vc4->is_vc5))
>  		return;
>  
> -	if (perfmon)
> -		refcount_inc(&perfmon->refcnt);
> +	refcount_inc(&perfmon->refcnt);
>  }
>  
>  void vc4_perfmon_put(struct vc4_perfmon *perfmon)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ