lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250326070441.1515428-1-liuqianyi125@gmail.com>
Date: Wed, 26 Mar 2025 15:04:41 +0800
From: Qianyi Liu <liuqianyi125@...il.com>
To: phasta@...lbox.org,
	airlied@...il.com,
	ckoenig.leichtzumerken@...il.com,
	dakr@...nel.org,
	daniel@...ll.ch,
	maarten.lankhorst@...ux.intel.com,
	matthew.brost@...el.com,
	mripard@...nel.org,
	phasta@...nel.org,
	tzimmermann@...e.de
Cc: dri-devel@...ts.freedesktop.org,
	linux-kernel@...r.kernel.org,
	liuqianyi125@...il.com
Subject: [PATCH] drm/sched: Add return value for drm_sched_entity_push_job

Currently drm_sched_entity_push_job() has no return value to indicate
operation status. This makes it difficult for callers to handle error
conditions properly.

Add a int return value to drm_sched_entity_push_job() that returns 0 on
success or a negative error code (e.g., -EINVAL) on failure. This allows
callers to:

1. Detect when job submission fails
2. Perform proper cleanup (e.g., release job and fence allocations)
3. Avoid potential memory leaks in error paths

Signed-off-by: Qianyi Liu <liuqianyi125@...il.com>
---
 drivers/gpu/drm/scheduler/sched_entity.c | 8 ++++++--
 include/drm/gpu_scheduler.h              | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
index bd39db7bb240..f31964e76062 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -579,8 +579,10 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)
  * fence sequence number this function should be called with drm_sched_job_arm()
  * under common lock for the struct drm_sched_entity that was set up for
  * @sched_job in drm_sched_job_init().
+ *
+ * Returns 0 on success or a negative error code on failure.
  */
-void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
+int drm_sched_entity_push_job(struct drm_sched_job *sched_job)
 {
 	struct drm_sched_entity *entity = sched_job->entity;
 	bool first;
@@ -609,7 +611,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
 			spin_unlock(&entity->lock);
 
 			DRM_ERROR("Trying to push to a killed entity\n");
-			return;
+			return -EINVAL;
 		}
 
 		rq = entity->rq;
@@ -626,5 +628,7 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
 
 		drm_sched_wakeup(sched);
 	}
+
+	return 0;
 }
 EXPORT_SYMBOL(drm_sched_entity_push_job);
diff --git a/include/drm/gpu_scheduler.h b/include/drm/gpu_scheduler.h
index 50928a7ae98e..48a263571bab 100644
--- a/include/drm/gpu_scheduler.h
+++ b/include/drm/gpu_scheduler.h
@@ -589,7 +589,7 @@ int drm_sched_job_init(struct drm_sched_job *job,
 		       struct drm_sched_entity *entity,
 		       u32 credits, void *owner);
 void drm_sched_job_arm(struct drm_sched_job *job);
-void drm_sched_entity_push_job(struct drm_sched_job *sched_job);
+int drm_sched_entity_push_job(struct drm_sched_job *sched_job);
 int drm_sched_job_add_dependency(struct drm_sched_job *job,
 				 struct dma_fence *fence);
 int drm_sched_job_add_syncobj_dependency(struct drm_sched_job *job,
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ