mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "陈涛涛 Taotao Chen" <chentaotao@didiglobal.com>
To: "jani.nikula@linux.intel.com" <jani.nikula@linux.intel.com>,
	"joonas.lahtinen@linux.intel.com"
	<joonas.lahtinen@linux.intel.com>,
	"rodrigo.vivi@intel.com" <rodrigo.vivi@intel.com>,
	"tursulin@ursulin.net" <tursulin@ursulin.net>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"simona@ffwll.ch" <simona@ffwll.ch>
Cc: "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>,
	"陈涛涛 Taotao Chen" <chentaotao@didiglobal.com>
Subject: [PATCH 2/2] drm/i915: Fix incorrect error handling in shmem_pwrite()
Date: Mon, 11 Aug 2025 09:31:00 +0000	[thread overview]
Message-ID: <20250811093050.38930-2-chentaotao@didiglobal.com> (raw)
In-Reply-To: <20250811093050.38930-1-chentaotao@didiglobal.com>

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;
+
 	return 0;
 }
 
-- 
2.34.1

  reply	other threads:[~2025-08-11  9:34 UTC|newest]

Thread overview: 9+ 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 ` 陈涛涛 Taotao Chen [this message]
2025-08-12 14:06   ` [PATCH 2/2] drm/i915: Fix incorrect error handling in shmem_pwrite() Rodrigo Vivi
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-12 14:03 ` 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=20250811093050.38930-2-chentaotao@didiglobal.com \
    --to=chentaotao@didiglobal.com \
    --cc=airlied@gmail.com \
    --cc=brauner@kernel.org \
    --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=rodrigo.vivi@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

all inboxes | Powered by JetHome®