diff mbox series

pci: hda: Add IRQ check for platform_get_irq()

Message ID 20210622131947.94346-1-jjcao20@fudan.edu.cn
State Accepted
Headers show
Series pci: hda: Add IRQ check for platform_get_irq() | expand

Commit Message

Jiajun Cao June 22, 2021, 1:19 p.m. UTC
The function hda_tegra_first_init() neglects to check the return
value after executing platform_get_irq().

hda_tegra_first_init() should check the return value (if negative
error number) for errors so as to not pass a negative value to
the devm_request_irq().

Fix it by adding a check for the return value irq_id.

Signed-off-by: Jiajun Cao <jjcao20@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
---
 sound/pci/hda/hda_tegra.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Thierry Reding June 22, 2021, 2:08 p.m. UTC | #1
On Tue, Jun 22, 2021 at 09:19:42PM +0800, Jiajun Cao wrote:
> The function hda_tegra_first_init() neglects to check the return
> value after executing platform_get_irq().
> 
> hda_tegra_first_init() should check the return value (if negative
> error number) for errors so as to not pass a negative value to
> the devm_request_irq().
> 
> Fix it by adding a check for the return value irq_id.
> 
> Signed-off-by: Jiajun Cao <jjcao20@fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
> ---
>  sound/pci/hda/hda_tegra.c | 3 +++
>  1 file changed, 3 insertions(+)

The original code is probably harmless because it looks like the call to
request_irq() would return -EINVAL if irq_id was a negative error code.

But checking the return value is still a good idea, so:

Reviewed-by: Thierry Reding <treding@nvidia.com>
Takashi Iwai June 22, 2021, 2:12 p.m. UTC | #2
On Tue, 22 Jun 2021 15:19:42 +0200,
Jiajun Cao wrote:
> 
> The function hda_tegra_first_init() neglects to check the return
> value after executing platform_get_irq().
> 
> hda_tegra_first_init() should check the return value (if negative
> error number) for errors so as to not pass a negative value to
> the devm_request_irq().
> 
> Fix it by adding a check for the return value irq_id.
> 
> Signed-off-by: Jiajun Cao <jjcao20@fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>

Applied, thanks.


Takashi
diff mbox series

Patch

diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
index 6f2b743b9d75..6c6dc3fcde60 100644
--- a/sound/pci/hda/hda_tegra.c
+++ b/sound/pci/hda/hda_tegra.c
@@ -262,6 +262,9 @@  static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev)
 	const char *sname, *drv_name = "tegra-hda";
 	struct device_node *np = pdev->dev.of_node;
 
+	if (irq_id < 0)
+		return irq_id;
+
 	err = hda_tegra_init_chip(chip, pdev);
 	if (err)
 		return err;