Skip to content

Commit 6ecf8a2

Browse files
committed
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 02c54de commit 6ecf8a2

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
@@ -436,6 +436,9 @@ static int fastrpc_map_lookup(struct fastrpc_user *fl, int fd,
436436

437437
static void fastrpc_buf_free(struct fastrpc_buf *buf)
438438
{
439+
if (!buf)
440+
return;
441+
439442
dma_free_coherent(buf->dev, buf->size, buf->virt,
440443
fastrpc_ipa_to_dma_addr(buf->fl->cctx, buf->dma_addr));
441444
kfree(buf);
@@ -553,8 +556,7 @@ static void fastrpc_context_free(struct kref *ref)
553556
for (i = 0; i < ctx->nbufs; i++)
554557
fastrpc_map_put(ctx->maps[i]);
555558

556-
if (ctx->buf)
557-
fastrpc_buf_free(ctx->buf);
559+
fastrpc_buf_free(ctx->buf);
558560

559561
spin_lock_irqsave(&cctx->lock, flags);
560562
idr_remove(&cctx->ctx_idr, FIELD_GET(FASTRPC_CTXID_MASK, ctx->ctxid));
@@ -1687,8 +1689,7 @@ static int fastrpc_device_release(struct inode *inode, struct file *file)
16871689
list_del(&fl->user);
16881690
spin_unlock_irqrestore(&cctx->lock, flags);
16891691

1690-
if (fl->init_mem)
1691-
fastrpc_buf_free(fl->init_mem);
1692+
fastrpc_buf_free(fl->init_mem);
16921693

16931694
list_for_each_entry_safe(ctx, n, &fl->pending, node) {
16941695
list_del(&ctx->node);

0 commit comments

Comments
 (0)