public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915:Move the code position to reduce the number of judgments
@ 2022-08-25  1:37 Lv qian
  2022-08-25  6:51 ` Jani Nikula
  0 siblings, 1 reply; 2+ messages in thread
From: Lv qian @ 2022-08-25  1:37 UTC (permalink / raw)
  To: jani.nikula, joonas.lahtinen, rodrigo.vivi, tvrtko.ursulin,
	airlied, daniel
  Cc: intel-gfx, dri-devel, linux-kernel, Lv qian

	If the kmalloc allocation is successful, the if is judged twice, 
	so I move the second judgment in to the first judgment.

Signed-off-by: Lv qian <lvqian@nfschina.com>
---
 drivers/gpu/drm/i915/i915_gpu_error.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index 32e92651ef7c..c8230a8beadb 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -112,10 +112,10 @@ static bool __i915_error_grow(struct drm_i915_error_state_buf *e, size_t len)
 	if (!e->buf) {
 		e->size = PAGE_ALIGN(len + 1);
 		e->buf = kmalloc(e->size, GFP_KERNEL);
-	}
-	if (!e->buf) {
-		e->err = -ENOMEM;
-		return false;
+		if (!e->buf) {
+			e->err = -ENOMEM;
+			return false;
+		}
 	}
 
 	return true;
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-25  6:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-25  1:37 [PATCH] drm/i915:Move the code position to reduce the number of judgments Lv qian
2022-08-25  6:51 ` Jani Nikula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox