Skip to contentSkip to conversation

erofs-utils: fix memory leak in z_erofs_qpl_get_job()

PATCH New Nithurshen 1 participant 1 message Mar 5 Library code

lore
Share & tools
lore

Nithurshen

author
#0 lore raw

PATCH 1/1 erofs-utils: fix memory leak in z_erofs_qpl_get_job()

If qpl_init_job() fails, the previously allocated job memory is not freed before returning. Fix this by adding a free(job) call in the error path.

---
 lib/decompress.c | 1 +
 1 file changed, 1 insertion(+)
lib/decompress.c +1 -0
index 3e7a173..e7ec83e 100644
@@ -149,6 +149,7 @@ static qpl_job *z_erofs_qpl_get_job(void)
 		status = qpl_init_job(execution_path, (qpl_job *)job->job);
 		if (status != QPL_STS_OK) {
 			erofs_err("failed to initialize job: %d", status);
+			free(job);
 			return ERR_PTR(-EOPNOTSUPP);
 		}
 		erofs_atomic_dec_return(&z_erofs_qpl_reclaim_quot);
Signature · 1 line
2.51.0