Skip to content

Commit

Permalink
irqchip: mtk-sysirq: Use IS_ERR() instead of NULL pointer check
Browse files Browse the repository at this point in the history
Beniamino noticed a bug that an invalid DT file for the mediatek interrupt
polarity extension will cause kernel oops.

The reason is that the interrupt polarity support for mediatek chips
merely checks for NULL pointer instead of a casted error return
value in mtk_sysirq_of_init() so any other casted error value passes
the NULL pointer check and causes a kernel panic when dereferenced.

Use IS_ERR() and return the error value via PTR_ERR().

[ jac: took V2 over V3 for diff formatting, hand-added V3 changes,
tweaked subject line. ]

Reported-by: Beniamino Galvani <b.galvani@gmail.com>
Signed-off-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
Link: https://lkml.kernel.org/r/1418205302-22531-1-git-send-email-yingjoe.chen@mediatek.com
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
  • Loading branch information
Yingjoe Chen authored and Jason Cooper committed Jan 7, 2015
1 parent 97bf6af commit 596c405
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/irqchip/irq-mtk-sysirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ static int __init mtk_sysirq_of_init(struct device_node *node,
return -ENOMEM;

chip_data->intpol_base = of_io_request_and_map(node, 0, "intpol");
if (!chip_data->intpol_base) {
if (IS_ERR(chip_data->intpol_base)) {
pr_err("mtk_sysirq: unable to map sysirq register\n");
ret = -ENOMEM;
ret = PTR_ERR(chip_data->intpol_base);
goto out_free;
}

Expand Down

0 comments on commit 596c405

Please sign in to comment.