* [PATCH] MIPS: Fixup for Pontential NULL pointer dereference
@ 2020-09-01 4:55 Tong Chen
0 siblings, 0 replies; only message in thread
From: Tong Chen @ 2020-09-01 4:55 UTC (permalink / raw)
To: tongchen126; +Cc: john, tsbogend, linux-mips, Tong Chen
This is a fixup In-Reply-To Bug 200577,
where pontential null pointer dereference may occur.
Signed-off-by: Tong Chen <tongchen@whu.edu.cn>
---
arch/mips/lantiq/xway/gptu.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/arch/mips/lantiq/xway/gptu.c b/arch/mips/lantiq/xway/gptu.c
index 3d5683e75cf1..3c4253e64541 100644
--- a/arch/mips/lantiq/xway/gptu.c
+++ b/arch/mips/lantiq/xway/gptu.c
@@ -117,11 +117,12 @@ static void gptu_disable(struct clk *clk)
free_irq(irqres[clk->bits].start, NULL);
}
-static inline void clkdev_add_gptu(struct device *dev, const char *con,
+static inline int clkdev_add_gptu(struct device *dev, const char *con,
unsigned int timer)
{
struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
-
+ if (!clk)
+ return 0;
clk->cl.dev_id = dev_name(dev);
clk->cl.con_id = con;
clk->cl.clk = clk;
@@ -129,12 +130,14 @@ static inline void clkdev_add_gptu(struct device *dev, const char *con,
clk->disable = gptu_disable;
clk->bits = timer;
clkdev_add(&clk->cl);
+ return 1;
}
static int gptu_probe(struct platform_device *pdev)
{
struct clk *clk;
struct resource *res;
+ int clk_num = 0;
if (of_irq_to_resource_table(pdev->dev.of_node, irqres, 6) != 6) {
dev_err(&pdev->dev, "Failed to get IRQ list\n");
@@ -169,14 +172,14 @@ static int gptu_probe(struct platform_device *pdev)
}
/* register the clocks */
- clkdev_add_gptu(&pdev->dev, "timer1a", TIMER1A);
- clkdev_add_gptu(&pdev->dev, "timer1b", TIMER1B);
- clkdev_add_gptu(&pdev->dev, "timer2a", TIMER2A);
- clkdev_add_gptu(&pdev->dev, "timer2b", TIMER2B);
- clkdev_add_gptu(&pdev->dev, "timer3a", TIMER3A);
- clkdev_add_gptu(&pdev->dev, "timer3b", TIMER3B);
-
- dev_info(&pdev->dev, "gptu: 6 timers loaded\n");
+ clk_num += clkdev_add_gptu(&pdev->dev, "timer1a", TIMER1A);
+ clk_num += clkdev_add_gptu(&pdev->dev, "timer1b", TIMER1B);
+ clk_num += clkdev_add_gptu(&pdev->dev, "timer2a", TIMER2A);
+ clk_num += clkdev_add_gptu(&pdev->dev, "timer2b", TIMER2B);
+ clk_num += clkdev_add_gptu(&pdev->dev, "timer3a", TIMER3A);
+ clk_num += clkdev_add_gptu(&pdev->dev, "timer3b", TIMER3B);
+
+ dev_info(&pdev->dev, "gptu: %d timers loaded\n", clk_num);
return 0;
}
--
2.28.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-01 4:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 4:55 [PATCH] MIPS: Fixup for Pontential NULL pointer dereference Tong Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).