Skip to content

Commit 10f8b57

Browse files
ekanshibuJianping-Li
authored andcommitted
FROMLIST: misc: fastrpc: Allow fastrpc_buf_free() to accept NULL
Make fastrpc_buf_free() a no-op when passed a NULL pointer, allowing callers to avoid open-coded NULL checks. Link: https://lore.kernel.org/all/20260409062617.1182-5-jianping.li@oss.qualcomm.com/ Co-developed-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com> Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com> Signed-off-by: Jianping Li <jianping.li@oss.qualcomm.com>
1 parent 3b0c335 commit 10f8b57

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/misc/fastrpc.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
416416

417417
static void fastrpc_buf_free(struct fastrpc_buf *buf)
418418
{
419+
if (!buf)
420+
return;
421+
419422
dma_free_coherent(buf->dev, buf->size, buf->virt,
420423
FASTRPC_PHYS(buf->phys));
421424
kfree(buf);
@@ -533,8 +536,7 @@ static void fastrpc_context_free(struct kref *ref)
533536
for (i = 0; i < ctx->nbufs; i++)
534537
fastrpc_map_put(ctx->maps[i]);
535538

536-
if (ctx->buf)
537-
fastrpc_buf_free(ctx->buf);
539+
fastrpc_buf_free(ctx->buf);
538540

539541
spin_lock_irqsave(&cctx->lock, flags);
540542
idr_remove(&cctx->ctx_idr, ctx->ctxid >> 8);
@@ -1664,8 +1666,7 @@ static int fastrpc_device_release(struct inode *inode, struct file *file)
16641666
list_del(&fl->user);
16651667
spin_unlock_irqrestore(&cctx->lock, flags);
16661668

1667-
if (fl->init_mem)
1668-
fastrpc_buf_free(fl->init_mem);
1669+
fastrpc_buf_free(fl->init_mem);
16691670

16701671
list_for_each_entry_safe(ctx, n, &fl->pending, node) {
16711672
list_del(&ctx->node);

0 commit comments

Comments
 (0)