From: Greg KH <gregkh@linuxfoundation.org>
To: Zheng Wang <zyytlz.wz@163.com>
Cc: hackerzheng666@gmail.com, 1002992920@qq.com, airlied@linux.ie,
alex000young@gmail.com, dri-devel@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org, jani.nikula@linux.intel.com,
linux-kernel@vger.kernel.org, security@kernel.org,
tvrtko.ursulin@linux.intel.com
Subject: Re: [PATCH] drm/i915/gvt: fix double free bug in split_2MB_gtt_entry
Date: Sun, 2 Oct 2022 16:18:27 +0200 [thread overview]
Message-ID: <Yzmds3DXu32EeSO5@kroah.com> (raw)
In-Reply-To: <20220928033340.1063949-1-zyytlz.wz@163.com>
On Wed, Sep 28, 2022 at 11:33:40AM +0800, Zheng Wang wrote:
> If intel_gvt_dma_map_guest_page failed, it will call
> ppgtt_invalidate_spt, which will finally free the spt.
> But the caller does not notice that, it will free spt again in error path.
>
> Fix this by only freeing spt in ppgtt_invalidate_spt in good case.
>
> Fixes: b901b252b6cf ("drm/i915/gvt: Add 2M huge gtt support")
> Reported-by: Zheng Wang <hackerzheng666@gmail.com>
> Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
> ---
> drivers/gpu/drm/i915/gvt/gtt.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
> index ce0eb03709c3..550519f0acca 100644
> --- a/drivers/gpu/drm/i915/gvt/gtt.c
> +++ b/drivers/gpu/drm/i915/gvt/gtt.c
> @@ -959,7 +959,7 @@ static inline int ppgtt_put_spt(struct intel_vgpu_ppgtt_spt *spt)
> return atomic_dec_return(&spt->refcount);
> }
>
> -static int ppgtt_invalidate_spt(struct intel_vgpu_ppgtt_spt *spt);
> +static int ppgtt_invalidate_spt(struct intel_vgpu_ppgtt_spt *spt, int is_error);
That is a horrible way to make an api (and it should be a bool too.)
Now every time you see this call in the code, you have to go look up
what the last parameter means. Just make 2 functions, one that does the
"is error" thing, and one that does not, and that will be much easier to
maintain and understand for the next 10+ years.
thanks,
greg k-h
next prev parent reply other threads:[~2022-10-02 14:17 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <tencent_ED24158E83CB9885E8BDD173EB5896B51906@qq.com>
2022-09-19 9:30 ` [PATCH] drm/i915/gvt: fix double-free bug in split_2MB_gtt_entry Jani Nikula
2022-09-19 9:55 ` Zheng Hacker
2022-09-21 9:13 ` Zheng Hacker
2022-09-28 3:33 ` [PATCH] drm/i915/gvt: fix double free " Zheng Wang
2022-10-02 14:18 ` Greg KH [this message]
2022-10-03 4:36 ` Zheng Hacker
2022-10-06 16:58 ` [PATCH v2] " Zheng Wang
2022-10-06 19:23 ` Greg KH
2022-10-07 0:39 ` Zheng Hacker
2022-10-07 1:37 ` [PATCH v3] " Zheng Wang
2022-10-27 0:01 ` Dave Airlie
2022-10-27 3:26 ` Zheng Hacker
2022-10-27 5:12 ` Dave Airlie
2022-10-30 15:10 ` Zheng Hacker
2022-12-15 10:47 ` Joonas Lahtinen
2022-12-15 11:33 ` Wang, Zhi A
2022-12-15 13:26 ` Zheng Hacker
2022-12-19 7:57 ` [Intel-gfx] " Zheng Wang
2022-12-19 8:22 ` Wang, Zhi A
2022-12-19 9:21 ` Zheng Wang
2022-12-19 12:46 ` [PATCH v4] [PATCH v4] " Zheng Wang
2022-12-19 12:52 ` [RESEND PATCH " Zheng Wang
2022-12-20 8:22 ` Zhenyu Wang
2022-12-20 9:03 ` Zheng Hacker
2022-12-20 9:40 ` [PATCH v5] " Zheng Wang
2022-12-21 2:58 ` Zhenyu Wang
2022-12-21 5:01 ` Zheng Hacker
2022-12-29 16:56 ` [PATCH v6] " Zheng Wang
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=Yzmds3DXu32EeSO5@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=1002992920@qq.com \
--cc=airlied@linux.ie \
--cc=alex000young@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hackerzheng666@gmail.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=security@kernel.org \
--cc=tvrtko.ursulin@linux.intel.com \
--cc=zyytlz.wz@163.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox