* [PATCH] accel/habanalabs: Use common error handling code in hl_cb_alloc()
@ 2026-06-10 18:35 Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2026-06-10 18:35 UTC (permalink / raw)
To: dri-devel, Kees Cook, Koby Elbaz, Konstantin Sinyuk, Oded Gabbay
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 10 Jun 2026 20:30:23 +0200
Use an additional label so that a bit of exception handling can be better
reused at the end of this function implementation.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/accel/habanalabs/common/command_buffer.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/accel/habanalabs/common/command_buffer.c b/drivers/accel/habanalabs/common/command_buffer.c
index e929db8bc023..980c9e4f96c6 100644
--- a/drivers/accel/habanalabs/common/command_buffer.c
+++ b/drivers/accel/habanalabs/common/command_buffer.c
@@ -126,10 +126,8 @@ static struct hl_cb *hl_cb_alloc(struct hl_device *hdev, u32 cb_size,
if (internal_cb) {
p = (void *) gen_pool_alloc(hdev->internal_cb_pool, cb_size);
- if (!p) {
- kfree(cb);
- return NULL;
- }
+ if (!p)
+ goto free_cb;
cb_offset = p - hdev->internal_cb_pool_virt_addr;
cb->is_internal = true;
@@ -147,14 +145,17 @@ static struct hl_cb *hl_cb_alloc(struct hl_device *hdev, u32 cb_size,
dev_err(hdev->dev,
"failed to allocate %d of dma memory for CB\n",
cb_size);
- kfree(cb);
- return NULL;
+ goto free_cb;
}
cb->kernel_address = p;
cb->size = cb_size;
return cb;
+
+free_cb:
+ kfree(cb);
+ return NULL;
}
struct hl_cb_mmap_mem_alloc_args {
--
2.54.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-10 18:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-10 18:35 [PATCH] accel/habanalabs: Use common error handling code in hl_cb_alloc() Markus Elfring
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®