Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: davinci: Handle return value of clk_prepare_enable

clk_prepare_enable() can fail here and we must check its return value.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Arvind Yadav and committed by
Linus Walleij
6dc0048c f37e335f

+9 -2
+9 -2
drivers/gpio/gpio-davinci.c
··· 437 437 { 438 438 unsigned gpio, bank; 439 439 int irq; 440 + int ret; 440 441 struct clk *clk; 441 442 u32 binten = 0; 442 443 unsigned ngpio, bank_irq; ··· 481 480 PTR_ERR(clk)); 482 481 return PTR_ERR(clk); 483 482 } 484 - clk_prepare_enable(clk); 483 + ret = clk_prepare_enable(clk); 484 + if (ret) 485 + return ret; 485 486 486 487 if (!pdata->gpio_unbanked) { 487 488 irq = devm_irq_alloc_descs(dev, -1, 0, ngpio, 0); 488 489 if (irq < 0) { 489 490 dev_err(dev, "Couldn't allocate IRQ numbers\n"); 491 + clk_disable_unprepare(clk); 490 492 return irq; 491 493 } 492 494 ··· 498 494 chips); 499 495 if (!irq_domain) { 500 496 dev_err(dev, "Couldn't register an IRQ domain\n"); 497 + clk_disable_unprepare(clk); 501 498 return -ENODEV; 502 499 } 503 500 } ··· 567 562 sizeof(struct 568 563 davinci_gpio_irq_data), 569 564 GFP_KERNEL); 570 - if (!irqdata) 565 + if (!irqdata) { 566 + clk_disable_unprepare(clk); 571 567 return -ENOMEM; 568 + } 572 569 573 570 irqdata->regs = g; 574 571 irqdata->bank_num = bank;