From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: "陈涛涛 Taotao Chen" <chentaotao@didiglobal.com>
Cc: "jani.nikula@linux.intel.com" <jani.nikula@linux.intel.com>,
"joonas.lahtinen@linux.intel.com"
<joonas.lahtinen@linux.intel.com>,
"tursulin@ursulin.net" <tursulin@ursulin.net>,
"airlied@gmail.com" <airlied@gmail.com>,
"simona@ffwll.ch" <simona@ffwll.ch>,
"oe-lkp@lists.linux.dev" <oe-lkp@lists.linux.dev>,
"lkp@intel.com" <lkp@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"brauner@kernel.org" <brauner@kernel.org>,
"oliver.sang@intel.com" <oliver.sang@intel.com>
Subject: Re: [PATCH 2/2] drm/i915: Fix incorrect error handling in shmem_pwrite()
Date: Tue, 12 Aug 2025 10:06:38 -0400 [thread overview]
Message-ID: <aJtKbg28QMPgvunP@intel.com> (raw)
In-Reply-To: <20250811093050.38930-2-chentaotao@didiglobal.com>
On Mon, Aug 11, 2025 at 09:31:00AM +0000, 陈涛涛 Taotao Chen wrote:
> From: Taotao Chen <chentaotao@didiglobal.com>
>
> shmem_pwrite() currently checks for short writes before negative error
> codes, which can overwrite real errors (e.g., -EFBIG) with -EIO.
> Reorder the checks to return negative errors first, then handle short
> writes.
>
> Fixes: 048832a3f400 ("drm/i915: Refactor shmem_pwrite() to use kiocb and write_iter")
> Signed-off-by: Taotao Chen <chentaotao@didiglobal.com>
> ---
> drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> index 2b53aad915f5..702532eef207 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> @@ -441,12 +441,12 @@ shmem_pwrite(struct drm_i915_gem_object *obj,
> written = file->f_op->write_iter(&kiocb, &iter);
> BUG_ON(written == -EIOCBQUEUED);
>
> - if (written != size)
> - return -EIO;
> -
> if (written < 0)
> return written;
>
> + if (written != size)
> + return -EIO;
That's awkward...
I mean, you are right that we cannot overwrite what is returned from the
write_iter function. But perhaps this != check here should be before?
Or it at least deserves a comment in the code telling what's the intent
here. why != size is -EIO... but it was already written :/
> +
> return 0;
> }
>
> --
> 2.34.1
next prev parent reply other threads:[~2025-08-12 14:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 9:30 [PATCH 1/2] drm/i915: set O_LARGEFILE in __create_shmem() 陈涛涛 Taotao Chen
2025-08-11 9:31 ` [PATCH 2/2] drm/i915: Fix incorrect error handling in shmem_pwrite() 陈涛涛 Taotao Chen
2025-08-12 14:06 ` Rodrigo Vivi [this message]
2025-08-20 17:03 ` Andi Shyti
2025-08-20 17:10 ` Andi Shyti
2025-08-21 3:21 ` [PATCH 1/2] drm/i915: set O_LARGEFILE in __create_shmem() 陈涛涛 Taotao Chen
2025-08-21 12:12 ` Andi Shyti
2025-08-11 10:21 ` ✗ LGCI.VerificationFailed: failure for series starting with [1/2] " Patchwork
2025-08-12 14:03 ` [PATCH 1/2] " Rodrigo Vivi
2025-08-20 21:31 ` Andi Shyti
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=aJtKbg28QMPgvunP@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=airlied@gmail.com \
--cc=brauner@kernel.org \
--cc=chentaotao@didiglobal.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-lkp@lists.linux.dev \
--cc=oliver.sang@intel.com \
--cc=simona@ffwll.ch \
--cc=tursulin@ursulin.net \
/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;
as well as URLs for NNTP newsgroup(s).