Skip to content

Commit d673b20

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/20260407100508.1027-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 6e1f183 commit d673b20

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

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);
@@ -1656,8 +1658,7 @@ static int fastrpc_device_release(struct inode *inode, struct file *file)
16561658
list_del(&fl->user);
16571659
spin_unlock_irqrestore(&cctx->lock, flags);
16581660

1659-
if (fl->init_mem)
1660-
fastrpc_buf_free(fl->init_mem);
1661+
fastrpc_buf_free(fl->init_mem);
16611662

16621663
list_for_each_entry_safe(ctx, n, &fl->pending, node) {
16631664
list_del(&ctx->node);

0 commit comments

Comments
 (0)