* [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
@ 2017-03-23 12:22 ` Colin King
0 siblings, 0 replies; 13+ messages in thread
From: Colin King @ 2017-03-23 12:22 UTC (permalink / raw)
To: Zhenyu Wang, Zhi Wang, Daniel Vetter, Jani Nikula, David Airlie,
intel-gvt-dev, intel-gfx, dri-devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
info is being checked to see if it is a null pointer, however, vpgu is
dereferencing info before this check, leading to a potential null
pointer dereference. If info is null, then the error message being
printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
use a null vpgu as the macro has a sanity check to see if vpgu is null,
so this is OK.
Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")
Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 1ea3eb270de8..f8619a772c44 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
{
- struct intel_vgpu *vgpu = info->vgpu;
-
if (!info) {
+ struct intel_vgpu *vgpu = NULL;
+
gvt_vgpu_err("kvmgt_guest_info invalid\n");
return false;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
@ 2017-03-23 12:22 ` Colin King
0 siblings, 0 replies; 13+ messages in thread
From: Colin King @ 2017-03-23 12:22 UTC (permalink / raw)
To: Zhenyu Wang, Zhi Wang, Daniel Vetter, Jani Nikula, David Airlie,
intel-gvt-dev, intel-gfx, dri-devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
info is being checked to see if it is a null pointer, however, vpgu is
dereferencing info before this check, leading to a potential null
pointer dereference. If info is null, then the error message being
printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
use a null vpgu as the macro has a sanity check to see if vpgu is null,
so this is OK.
Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")
Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 1ea3eb270de8..f8619a772c44 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
{
- struct intel_vgpu *vgpu = info->vgpu;
-
if (!info) {
+ struct intel_vgpu *vgpu = NULL;
+
gvt_vgpu_err("kvmgt_guest_info invalid\n");
return false;
}
--
2.11.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
2017-03-23 12:22 ` Colin King
(?)
@ 2017-03-23 12:39 ` Chris Wilson
-1 siblings, 0 replies; 13+ messages in thread
From: Chris Wilson @ 2017-03-23 12:39 UTC (permalink / raw)
To: Colin King
Cc: Zhenyu Wang, Zhi Wang, Daniel Vetter, Jani Nikula, David Airlie,
intel-gvt-dev, intel-gfx, dri-devel, kernel-janitors,
linux-kernel
On Thu, Mar 23, 2017 at 12:22:30PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> info is being checked to see if it is a null pointer, however, vpgu is
> dereferencing info before this check, leading to a potential null
> pointer dereference. If info is null, then the error message being
> printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> use a null vpgu as the macro has a sanity check to see if vpgu is null,
> so this is OK.
It is never NULL, it gets checked by its only caller.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
@ 2017-03-23 12:39 ` Chris Wilson
0 siblings, 0 replies; 13+ messages in thread
From: Chris Wilson @ 2017-03-23 12:39 UTC (permalink / raw)
To: Colin King
Cc: dri-devel, David Airlie, intel-gfx, kernel-janitors,
linux-kernel, Daniel Vetter, intel-gvt-dev
On Thu, Mar 23, 2017 at 12:22:30PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> info is being checked to see if it is a null pointer, however, vpgu is
> dereferencing info before this check, leading to a potential null
> pointer dereference. If info is null, then the error message being
> printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> use a null vpgu as the macro has a sanity check to see if vpgu is null,
> so this is OK.
It is never NULL, it gets checked by its only caller.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
@ 2017-03-23 12:39 ` Chris Wilson
0 siblings, 0 replies; 13+ messages in thread
From: Chris Wilson @ 2017-03-23 12:39 UTC (permalink / raw)
To: Colin King
Cc: dri-devel, David Airlie, intel-gfx, kernel-janitors,
linux-kernel, Daniel Vetter, intel-gvt-dev
On Thu, Mar 23, 2017 at 12:22:30PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> info is being checked to see if it is a null pointer, however, vpgu is
> dereferencing info before this check, leading to a potential null
> pointer dereference. If info is null, then the error message being
> printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> use a null vpgu as the macro has a sanity check to see if vpgu is null,
> so this is OK.
It is never NULL, it gets checked by its only caller.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 13+ messages in thread
* ✗ Fi.CI.BAT: warning for drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
2017-03-23 12:22 ` Colin King
(?)
(?)
@ 2017-03-23 13:16 ` Patchwork
-1 siblings, 0 replies; 13+ messages in thread
From: Patchwork @ 2017-03-23 13:16 UTC (permalink / raw)
To: Colin King; +Cc: intel-gfx
== Series Details ==
Series: drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
URL : https://patchwork.freedesktop.org/series/21762/
State : warning
== Summary ==
Series 21762v1 drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
https://patchwork.freedesktop.org/api/1.0/series/21762/revisions/1/mbox/
Test gem_exec_flush:
Subgroup basic-batch-kernel-default-uc:
fail -> PASS (fi-snb-2600) fdo#100007
Test gem_exec_suspend:
Subgroup basic-s4-devices:
pass -> DMESG-WARN (fi-snb-2600)
fdo#100007 https://bugs.freedesktop.org/show_bug.cgi?id=100007
fi-bdw-5557u total:278 pass:267 dwarn:0 dfail:0 fail:0 skip:11 time: 455s
fi-bdw-gvtdvm total:278 pass:256 dwarn:8 dfail:0 fail:0 skip:14 time: 456s
fi-bsw-n3050 total:278 pass:239 dwarn:0 dfail:0 fail:0 skip:39 time: 582s
fi-bxt-j4205 total:278 pass:259 dwarn:0 dfail:0 fail:0 skip:19 time: 547s
fi-byt-j1900 total:278 pass:251 dwarn:0 dfail:0 fail:0 skip:27 time: 508s
fi-byt-n2820 total:278 pass:247 dwarn:0 dfail:0 fail:0 skip:31 time: 507s
fi-hsw-4770 total:278 pass:262 dwarn:0 dfail:0 fail:0 skip:16 time: 441s
fi-hsw-4770r total:278 pass:262 dwarn:0 dfail:0 fail:0 skip:16 time: 434s
fi-ilk-650 total:278 pass:228 dwarn:0 dfail:0 fail:0 skip:50 time: 441s
fi-ivb-3520m total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time: 521s
fi-ivb-3770 total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time: 496s
fi-kbl-7500u total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time: 485s
fi-skl-6260u total:278 pass:268 dwarn:0 dfail:0 fail:0 skip:10 time: 486s
fi-skl-6700hq total:278 pass:261 dwarn:0 dfail:0 fail:0 skip:17 time: 603s
fi-skl-6700k total:278 pass:256 dwarn:4 dfail:0 fail:0 skip:18 time: 484s
fi-skl-6770hq total:278 pass:268 dwarn:0 dfail:0 fail:0 skip:10 time: 523s
fi-skl-gvtdvm total:278 pass:265 dwarn:0 dfail:0 fail:0 skip:13 time: 465s
fi-snb-2520m total:278 pass:250 dwarn:0 dfail:0 fail:0 skip:28 time: 546s
fi-snb-2600 total:278 pass:248 dwarn:1 dfail:0 fail:0 skip:29 time: 420s
f99a2e3df860d56c83a726a1183162cb467b2ad4 drm-tip: 2017y-03m-23d-12h-06m-41s UTC integration manifest
eee6d67 drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4277/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
2017-03-23 12:22 ` Colin King
@ 2017-03-23 13:43 ` Frans Klaver
-1 siblings, 0 replies; 13+ messages in thread
From: Frans Klaver @ 2017-03-23 13:43 UTC (permalink / raw)
To: Colin King
Cc: Zhenyu Wang, Zhi Wang, Daniel Vetter, Jani Nikula, David Airlie,
intel-gvt-dev, intel-gfx, DRI mailing list, kernel-janitors,
linux-kernel
On Thu, Mar 23, 2017 at 1:22 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> info is being checked to see if it is a null pointer, however, vpgu is
> dereferencing info before this check, leading to a potential null
> pointer dereference. If info is null, then the error message being
> printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> use a null vpgu as the macro has a sanity check to see if vpgu is null,
> so this is OK.
>
> Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")
s,nefore,before,
>
> Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index 1ea3eb270de8..f8619a772c44 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
>
> static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
> {
> - struct intel_vgpu *vgpu = info->vgpu;
> -
> if (!info) {
> + struct intel_vgpu *vgpu = NULL;
> +
> gvt_vgpu_err("kvmgt_guest_info invalid\n");
> return false;
> }
Does this mean the original gvt_err() macro is no longer there?
And apparently gvt_vgpu_err is a macro that depends on the specifics
of its environment? Yikes.
Cheers,
Frans
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
@ 2017-03-23 13:43 ` Frans Klaver
0 siblings, 0 replies; 13+ messages in thread
From: Frans Klaver @ 2017-03-23 13:43 UTC (permalink / raw)
To: Colin King
Cc: Zhenyu Wang, Zhi Wang, Daniel Vetter, Jani Nikula, David Airlie,
intel-gvt-dev, intel-gfx, DRI mailing list, kernel-janitors,
linux-kernel
On Thu, Mar 23, 2017 at 1:22 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> info is being checked to see if it is a null pointer, however, vpgu is
> dereferencing info before this check, leading to a potential null
> pointer dereference. If info is null, then the error message being
> printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> use a null vpgu as the macro has a sanity check to see if vpgu is null,
> so this is OK.
>
> Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")
s,nefore,before,
>
> Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index 1ea3eb270de8..f8619a772c44 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
>
> static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
> {
> - struct intel_vgpu *vgpu = info->vgpu;
> -
> if (!info) {
> + struct intel_vgpu *vgpu = NULL;
> +
> gvt_vgpu_err("kvmgt_guest_info invalid\n");
> return false;
> }
Does this mean the original gvt_err() macro is no longer there?
And apparently gvt_vgpu_err is a macro that depends on the specifics
of its environment? Yikes.
Cheers,
Frans
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
2017-03-23 12:39 ` Chris Wilson
(?)
(?)
@ 2017-03-23 14:11 ` Joonas Lahtinen
2017-03-24 3:06 ` Zhenyu Wang
-1 siblings, 1 reply; 13+ messages in thread
From: Joonas Lahtinen @ 2017-03-23 14:11 UTC (permalink / raw)
To: Zhenyu Wang, Zhi Wang; +Cc: Daniel Vetter, intel-gfx
Dropping the irrelevant Cc's.
On to, 2017-03-23 at 12:39 +0000, Chris Wilson wrote:
> On Thu, Mar 23, 2017 at 12:22:30PM +0000, Colin King wrote:
> >
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > info is being checked to see if it is a null pointer, however, vpgu is
> > dereferencing info before this check, leading to a potential null
> > pointer dereference. If info is null, then the error message being
> > printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> > use a null vpgu as the macro has a sanity check to see if vpgu is null,
> > so this is OK.
>
> It is never NULL, it gets checked by its only caller.
Took me a while to make any sense of the code as gvt_vgpu_err depends
on a vgpu variable being declared in the scope without taking it as a
parameter and that is a one big no-no:
https://01.org/linuxgraphics/gfx-docs/drm/process/coding-style.html#macros-enums-and-rtl
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
2017-03-23 14:11 ` Joonas Lahtinen
@ 2017-03-24 3:06 ` Zhenyu Wang
0 siblings, 0 replies; 13+ messages in thread
From: Zhenyu Wang @ 2017-03-24 3:06 UTC (permalink / raw)
To: Joonas Lahtinen; +Cc: Daniel Vetter, intel-gfx
[-- Attachment #1.1: Type: text/plain, Size: 1250 bytes --]
On 2017.03.23 16:11:00 +0200, Joonas Lahtinen wrote:
> Dropping the irrelevant Cc's.
>
> On to, 2017-03-23 at 12:39 +0000, Chris Wilson wrote:
> > On Thu, Mar 23, 2017 at 12:22:30PM +0000, Colin King wrote:
> > >
> > > From: Colin Ian King <colin.king@canonical.com>
> > >
> > > info is being checked to see if it is a null pointer, however, vpgu is
> > > dereferencing info before this check, leading to a potential null
> > > pointer dereference. If info is null, then the error message being
> > > printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> > > use a null vpgu as the macro has a sanity check to see if vpgu is null,
> > > so this is OK.
> >
> > It is never NULL, it gets checked by its only caller.
>
> Took me a while to make any sense of the code as gvt_vgpu_err depends
> on a vgpu variable being declared in the scope without taking it as a
> parameter and that is a one big no-no:
>
> https://01.org/linuxgraphics/gfx-docs/drm/process/coding-style.html#macros-enums-and-rtl
>
Thanks for comment, Joonas. Current gvt dbg print is still a mess,
we will try to clean it up.
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 163 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
2017-03-23 13:43 ` Frans Klaver
(?)
@ 2017-03-24 3:38 ` Zhenyu Wang
-1 siblings, 0 replies; 13+ messages in thread
From: Zhenyu Wang @ 2017-03-24 3:38 UTC (permalink / raw)
To: Frans Klaver
Cc: Colin King, DRI mailing list, David Airlie, intel-gfx,
kernel-janitors, linux-kernel, Jani Nikula, Zhenyu Wang,
Daniel Vetter, intel-gvt-dev, Zhi Wang, Zhang, Tina
[-- Attachment #1: Type: text/plain, Size: 1982 bytes --]
On 2017.03.23 14:43:44 +0100, Frans Klaver wrote:
> On Thu, Mar 23, 2017 at 1:22 PM, Colin King <colin.king@canonical.com> wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > info is being checked to see if it is a null pointer, however, vpgu is
> > dereferencing info before this check, leading to a potential null
> > pointer dereference. If info is null, then the error message being
> > printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> > use a null vpgu as the macro has a sanity check to see if vpgu is null,
> > so this is OK.
> >
> > Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")
>
> s,nefore,before,
>
>
> >
> > Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> > index 1ea3eb270de8..f8619a772c44 100644
> > --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> > +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> > @@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
> >
> > static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
> > {
> > - struct intel_vgpu *vgpu = info->vgpu;
> > -
> > if (!info) {
> > + struct intel_vgpu *vgpu = NULL;
> > +
> > gvt_vgpu_err("kvmgt_guest_info invalid\n");
> > return false;
> > }
>
> Does this mean the original gvt_err() macro is no longer there?
>
> And apparently gvt_vgpu_err is a macro that depends on the specifics
> of its environment? Yikes.
>
The null check is redundant there, we can just remove that block and extra
vgpu variable.
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 163 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
@ 2017-03-24 3:38 ` Zhenyu Wang
0 siblings, 0 replies; 13+ messages in thread
From: Zhenyu Wang @ 2017-03-24 3:38 UTC (permalink / raw)
To: Frans Klaver
Cc: intel-gfx, kernel-janitors, linux-kernel, DRI mailing list,
Zhang, Tina, Daniel Vetter, Colin King, intel-gvt-dev, Zhi Wang
[-- Attachment #1: Type: text/plain, Size: 1982 bytes --]
On 2017.03.23 14:43:44 +0100, Frans Klaver wrote:
> On Thu, Mar 23, 2017 at 1:22 PM, Colin King <colin.king@canonical.com> wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > info is being checked to see if it is a null pointer, however, vpgu is
> > dereferencing info before this check, leading to a potential null
> > pointer dereference. If info is null, then the error message being
> > printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> > use a null vpgu as the macro has a sanity check to see if vpgu is null,
> > so this is OK.
> >
> > Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")
>
> s,nefore,before,
>
>
> >
> > Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> > index 1ea3eb270de8..f8619a772c44 100644
> > --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> > +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> > @@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
> >
> > static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
> > {
> > - struct intel_vgpu *vgpu = info->vgpu;
> > -
> > if (!info) {
> > + struct intel_vgpu *vgpu = NULL;
> > +
> > gvt_vgpu_err("kvmgt_guest_info invalid\n");
> > return false;
> > }
>
> Does this mean the original gvt_err() macro is no longer there?
>
> And apparently gvt_vgpu_err is a macro that depends on the specifics
> of its environment? Yikes.
>
The null check is redundant there, we can just remove that block and extra
vgpu variable.
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 163 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer
@ 2017-03-24 3:38 ` Zhenyu Wang
0 siblings, 0 replies; 13+ messages in thread
From: Zhenyu Wang @ 2017-03-24 3:38 UTC (permalink / raw)
To: Frans Klaver
Cc: intel-gfx, kernel-janitors, linux-kernel, DRI mailing list,
Zhang, Tina, Daniel Vetter, Colin King, intel-gvt-dev, Zhi Wang
[-- Attachment #1.1: Type: text/plain, Size: 1982 bytes --]
On 2017.03.23 14:43:44 +0100, Frans Klaver wrote:
> On Thu, Mar 23, 2017 at 1:22 PM, Colin King <colin.king@canonical.com> wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > info is being checked to see if it is a null pointer, however, vpgu is
> > dereferencing info before this check, leading to a potential null
> > pointer dereference. If info is null, then the error message being
> > printed by macro gvt_vgpu_err and this requires vpgu to exist. We can
> > use a null vpgu as the macro has a sanity check to see if vpgu is null,
> > so this is OK.
> >
> > Detected with CoverityScan, CID#1420672 ("Dereference nefore null check")
>
> s,nefore,before,
>
>
> >
> > Fixes: 695fbc08d80f ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > drivers/gpu/drm/i915/gvt/kvmgt.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> > index 1ea3eb270de8..f8619a772c44 100644
> > --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> > +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> > @@ -1339,9 +1339,9 @@ static int kvmgt_guest_init(struct mdev_device *mdev)
> >
> > static bool kvmgt_guest_exit(struct kvmgt_guest_info *info)
> > {
> > - struct intel_vgpu *vgpu = info->vgpu;
> > -
> > if (!info) {
> > + struct intel_vgpu *vgpu = NULL;
> > +
> > gvt_vgpu_err("kvmgt_guest_info invalid\n");
> > return false;
> > }
>
> Does this mean the original gvt_err() macro is no longer there?
>
> And apparently gvt_vgpu_err is a macro that depends on the specifics
> of its environment? Yikes.
>
The null check is redundant there, we can just remove that block and extra
vgpu variable.
--
Open Source Technology Center, Intel ltd.
$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 163 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2017-03-24 3:39 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-23 12:22 [PATCH] drm/i915/kvmgt: avoid dereferencing a potentially null info pointer Colin King
2017-03-23 12:22 ` Colin King
2017-03-23 12:39 ` Chris Wilson
2017-03-23 12:39 ` Chris Wilson
2017-03-23 12:39 ` Chris Wilson
2017-03-23 14:11 ` Joonas Lahtinen
2017-03-24 3:06 ` Zhenyu Wang
2017-03-23 13:16 ` ✗ Fi.CI.BAT: warning for " Patchwork
2017-03-23 13:43 ` [PATCH] " Frans Klaver
2017-03-23 13:43 ` Frans Klaver
2017-03-24 3:38 ` Zhenyu Wang
2017-03-24 3:38 ` Zhenyu Wang
2017-03-24 3:38 ` Zhenyu Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.