From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Zhenyu Wang <zhenyuw@linux.intel.com>, Joe Perches <joe@perches.com>
Cc: fred gao <fred.gao@intel.com>,
intel-gfx@lists.freedesktop.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Colin King <colin.king@canonical.com>,
intel-gvt-dev@lists.freedesktop.org,
Zhi Wang <zhi.a.wang@intel.com>
Subject: Re: [PATCH][drm-next] drm/i915/gvt: ensure -ve return value is handled correctly
Date: Thu, 21 Sep 2017 14:31:58 +0000 [thread overview]
Message-ID: <1506004318.5382.4.camel@linux.intel.com> (raw)
In-Reply-To: <20170920224406.jscthkglwfy3xhtf@zhen-hp.sh.intel.com>
On Thu, 2017-09-21 at 06:44 +0800, Zhenyu Wang wrote:
> On 2017.09.19 19:35:23 -0700, Joe Perches wrote:
> > On Wed, 2017-09-20 at 05:46 +0800, Zhenyu Wang wrote:
> > > On 2017.09.19 16:55:34 +0100, Colin King wrote:
> > > > From: Colin Ian King <colin.king@canonical.com>
> > > >
> > > > An earlier fix changed the return type from find_bb_size however the
> > > > integer return is being assigned to a unsigned int so the -ve error
> > > > check will never be detected. Make bb_size an int to fix this.
> > > >
> > > > Detected by CoverityScan CID#1456886 ("Unsigned compared against 0")
> > > >
> > > > Fixes: 1e3197d6ad73 ("drm/i915/gvt: Refine error handling for perform_bb_shadow")
> > > > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > > > ---
> > > > drivers/gpu/drm/i915/gvt/cmd_parser.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
> > > > index 2c0ccbb817dc..f41cbf664b69 100644
> > > > --- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
> > > > +++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
> > > > @@ -1628,7 +1628,7 @@ static int perform_bb_shadow(struct parser_exec_state *s)
> > > > struct intel_shadow_bb_entry *entry_obj;
> > > > struct intel_vgpu *vgpu = s->vgpu;
> > > > unsigned long gma = 0;
> > > > - uint32_t bb_size;
> > > > + int bb_size;
> > > > void *dst = NULL;
> > > > int ret = 0;
> > > >
> > >
> > > Applied this, thanks!
> >
> > Is it possible for bb_size to be both >= 2g and valid?
>
> Never be possible in practise and if really that big I think something
> is already insane indeed.
It's good idea to document these assumptions as WARN_ON's. In i915, if
the value is completely internal to kernel, we're using GEM_BUG_ON for
these so that our CI will notice breakage. If it's not a driver
internal value only, a WARN_ON is the appropriate action.
Otherwise the information is lost and the next person reading the code
will have the same question in mind.
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
WARNING: multiple messages have this Message-ID (diff)
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Zhenyu Wang <zhenyuw@linux.intel.com>, Joe Perches <joe@perches.com>
Cc: fred gao <fred.gao@intel.com>,
intel-gfx@lists.freedesktop.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Colin King <colin.king@canonical.com>,
intel-gvt-dev@lists.freedesktop.org,
Zhi Wang <zhi.a.wang@intel.com>
Subject: Re: [PATCH][drm-next] drm/i915/gvt: ensure -ve return value is handled correctly
Date: Thu, 21 Sep 2017 17:31:58 +0300 [thread overview]
Message-ID: <1506004318.5382.4.camel@linux.intel.com> (raw)
In-Reply-To: <20170920224406.jscthkglwfy3xhtf@zhen-hp.sh.intel.com>
On Thu, 2017-09-21 at 06:44 +0800, Zhenyu Wang wrote:
> On 2017.09.19 19:35:23 -0700, Joe Perches wrote:
> > On Wed, 2017-09-20 at 05:46 +0800, Zhenyu Wang wrote:
> > > On 2017.09.19 16:55:34 +0100, Colin King wrote:
> > > > From: Colin Ian King <colin.king@canonical.com>
> > > >
> > > > An earlier fix changed the return type from find_bb_size however the
> > > > integer return is being assigned to a unsigned int so the -ve error
> > > > check will never be detected. Make bb_size an int to fix this.
> > > >
> > > > Detected by CoverityScan CID#1456886 ("Unsigned compared against 0")
> > > >
> > > > Fixes: 1e3197d6ad73 ("drm/i915/gvt: Refine error handling for perform_bb_shadow")
> > > > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > > > ---
> > > > drivers/gpu/drm/i915/gvt/cmd_parser.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
> > > > index 2c0ccbb817dc..f41cbf664b69 100644
> > > > --- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
> > > > +++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
> > > > @@ -1628,7 +1628,7 @@ static int perform_bb_shadow(struct parser_exec_state *s)
> > > > struct intel_shadow_bb_entry *entry_obj;
> > > > struct intel_vgpu *vgpu = s->vgpu;
> > > > unsigned long gma = 0;
> > > > - uint32_t bb_size;
> > > > + int bb_size;
> > > > void *dst = NULL;
> > > > int ret = 0;
> > > >
> > >
> > > Applied this, thanks!
> >
> > Is it possible for bb_size to be both >= 2g and valid?
>
> Never be possible in practise and if really that big I think something
> is already insane indeed.
It's good idea to document these assumptions as WARN_ON's. In i915, if
the value is completely internal to kernel, we're using GEM_BUG_ON for
these so that our CI will notice breakage. If it's not a driver
internal value only, a WARN_ON is the appropriate action.
Otherwise the information is lost and the next person reading the code
will have the same question in mind.
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Zhenyu Wang <zhenyuw@linux.intel.com>, Joe Perches <joe@perches.com>
Cc: Colin King <colin.king@canonical.com>,
fred gao <fred.gao@intel.com>, Zhi Wang <zhi.a.wang@intel.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
David Airlie <airlied@linux.ie>,
intel-gvt-dev@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][drm-next] drm/i915/gvt: ensure -ve return value is handled correctly
Date: Thu, 21 Sep 2017 17:31:58 +0300 [thread overview]
Message-ID: <1506004318.5382.4.camel@linux.intel.com> (raw)
In-Reply-To: <20170920224406.jscthkglwfy3xhtf@zhen-hp.sh.intel.com>
On Thu, 2017-09-21 at 06:44 +0800, Zhenyu Wang wrote:
> On 2017.09.19 19:35:23 -0700, Joe Perches wrote:
> > On Wed, 2017-09-20 at 05:46 +0800, Zhenyu Wang wrote:
> > > On 2017.09.19 16:55:34 +0100, Colin King wrote:
> > > > From: Colin Ian King <colin.king@canonical.com>
> > > >
> > > > An earlier fix changed the return type from find_bb_size however the
> > > > integer return is being assigned to a unsigned int so the -ve error
> > > > check will never be detected. Make bb_size an int to fix this.
> > > >
> > > > Detected by CoverityScan CID#1456886 ("Unsigned compared against 0")
> > > >
> > > > Fixes: 1e3197d6ad73 ("drm/i915/gvt: Refine error handling for perform_bb_shadow")
> > > > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > > > ---
> > > > drivers/gpu/drm/i915/gvt/cmd_parser.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c
> > > > index 2c0ccbb817dc..f41cbf664b69 100644
> > > > --- a/drivers/gpu/drm/i915/gvt/cmd_parser.c
> > > > +++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c
> > > > @@ -1628,7 +1628,7 @@ static int perform_bb_shadow(struct parser_exec_state *s)
> > > > struct intel_shadow_bb_entry *entry_obj;
> > > > struct intel_vgpu *vgpu = s->vgpu;
> > > > unsigned long gma = 0;
> > > > - uint32_t bb_size;
> > > > + int bb_size;
> > > > void *dst = NULL;
> > > > int ret = 0;
> > > >
> > >
> > > Applied this, thanks!
> >
> > Is it possible for bb_size to be both >= 2g and valid?
>
> Never be possible in practise and if really that big I think something
> is already insane indeed.
It's good idea to document these assumptions as WARN_ON's. In i915, if
the value is completely internal to kernel, we're using GEM_BUG_ON for
these so that our CI will notice breakage. If it's not a driver
internal value only, a WARN_ON is the appropriate action.
Otherwise the information is lost and the next person reading the code
will have the same question in mind.
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
next prev parent reply other threads:[~2017-09-21 14:31 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-19 15:55 [PATCH][drm-next] drm/i915/gvt: ensure -ve return value is handled correctly Colin King
2017-09-19 15:55 ` Colin King
2017-09-19 15:55 ` Colin King
2017-09-19 20:05 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-09-19 21:46 ` [PATCH][drm-next] " Zhenyu Wang
2017-09-19 21:46 ` Zhenyu Wang
2017-09-19 21:46 ` Zhenyu Wang
2017-09-20 2:35 ` Joe Perches
2017-09-20 2:35 ` Joe Perches
2017-09-20 2:35 ` Joe Perches
2017-09-20 22:44 ` Zhenyu Wang
2017-09-20 22:44 ` Zhenyu Wang
2017-09-20 22:44 ` Zhenyu Wang
2017-09-21 14:31 ` Joonas Lahtinen [this message]
2017-09-21 14:31 ` Joonas Lahtinen
2017-09-21 14:31 ` Joonas Lahtinen
2017-09-21 16:17 ` Wang, Zhi A
2017-09-21 16:17 ` Wang, Zhi A
2017-09-21 16:17 ` Wang, Zhi A
2017-09-22 11:11 ` Joonas Lahtinen
2017-09-22 11:11 ` Joonas Lahtinen
2017-09-22 11:11 ` Joonas Lahtinen
2017-09-22 17:50 ` Wang, Zhi A
2017-09-22 17:50 ` Wang, Zhi A
2017-09-22 17:50 ` Wang, Zhi A
2017-09-25 9:32 ` Joonas Lahtinen
2017-09-25 9:32 ` Joonas Lahtinen
2017-09-19 23:24 ` ✓ Fi.CI.IGT: success for " Patchwork
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=1506004318.5382.4.camel@linux.intel.com \
--to=joonas.lahtinen@linux.intel.com \
--cc=colin.king@canonical.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=fred.gao@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=joe@perches.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=zhenyuw@linux.intel.com \
--cc=zhi.a.wang@intel.com \
/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 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.