Skip to content

Commit

Permalink
mailbox: mediatek: Add check for possible failure of kzalloc
Browse files Browse the repository at this point in the history
The patch 623a614("mailbox: mediatek: Add Mediatek CMDQ driver")
introduce the following static checker warning:
  drivers/mailbox/mtk-cmdq-mailbox.c:366 cmdq_mbox_send_data()
  error: potential null dereference 'task'.  (kzalloc returns null)

Fixes: 623a614 ("mailbox: mediatek: Add Mediatek CMDQ driver")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Houlong Wei <houlong.wei@mediatek.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
  • Loading branch information
Houlong Wei authored and Jassi Brar committed Sep 29, 2018
1 parent 462f668 commit 9f0a0a3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/mailbox/mtk-cmdq-mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ static int cmdq_mbox_send_data(struct mbox_chan *chan, void *data)
WARN_ON(cmdq->suspended);

task = kzalloc(sizeof(*task), GFP_ATOMIC);
if (!task)
return -ENOMEM;

task->cmdq = cmdq;
INIT_LIST_HEAD(&task->list_entry);
task->pa_base = pkt->pa_base;
Expand Down

0 comments on commit 9f0a0a3

Please sign in to comment.