Skip to contentSkip to conversation

Driver core: platform: Add extra error check in devm_platform_get_irqs_affinity()

PATCH Applied John Garry 4 participants 6 messages Dec 21, 2020 – Jan 8, 2021 Driver core

lore
Share & tools
lore

John Garry

author
#0 lore raw

PATCH 1/1 Driver core: platform: Add extra error check in devm_platform_get_irqs_affinity()

The current check of nvec < minvec for nvec returned from platform_irq_count() will not detect a negative error code in nvec.

This is because minvec is unsigned, and, as such, nvec is promoted to unsigned in that check, which will make it a huge number (if it contained -EPROBE_DEFER).

In practice, an error should not occur in nvec for the only in-tree user, but add a check anyway.

Fixes e15f2fa959f2 ("driver core: platform: Add devm_platform_get_irqs_affinity()")

---
I hope that this can go through either irqchip or driver/core trees, thanks!

drivers/base/platform.c +2 -0
index 95fd1549f87d..8456d8384ac8 100644
@@ -366,6 +366,8 @@ int devm_platform_get_irqs_affinity(struct platform_device *dev,
 		return -ERANGE;
 
 	nvec = platform_irq_count(dev);
+	if (nvec < 0)
+		return nvec;
 
 	if (nvec < minvec)
 		return -ENOSPC;
Signature · 1 line
2.26.2
merge bot Applied
#1 lore raw

[irqchip: irq/irqchip-next] driver core: platform: Add extra error check in devm_platform_get_irqs_affinity()

The following commit has been merged into the irq/irqchip-next branch of irqchip:

The following commit has been merged into the irq/irqchip-next branch of irqchip:

Commit-ID:     e1dc20995cb9fa04b46e8f37113a7203c906d2bf
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/e1dc20995cb9fa04b46e8f37113a7203c906d2bf
Author:        John Garry <[email protected]>
AuthorDate:    Mon, 21 Dec 2020 22:30:55 +08:00
Committer:     Marc Zyngier <[email protected]>
CommitterDate: Tue, 22 Dec 2020 08:06:38 

driver core: platform: Add extra error check in devm_platform_get_irqs_affinity()

The current check of nvec < minvec for nvec returned from platform_irq_count() will not detect a negative error code in nvec.

This is because minvec is unsigned, and, as such, nvec is promoted to unsigned in that check, which will make it a huge number (if it contained -EPROBE_DEFER).

In practice, an error should not occur in nvec for the only in-tree user, but add a check anyway.

Fixes e15f2fa959f2 ("driver core: platform: Add devm_platform_get_irqs_affinity()")
---
 drivers/base/platform.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/base/platform.c +2 -0
index ea8add1..74c97b6 100644
@@ -351,6 +351,8 @@ int devm_platform_get_irqs_affinity(struct platform_device *dev,
 		return -ERANGE;
 
 	nvec = platform_irq_count(dev);
+	if (nvec < 0)
+		return nvec;
 
 	if (nvec < minvec)
 		return -ENOSPC;
maintainer
#2 lore raw
In reply to John Garry
Quoted 7 lines · John Garry

The current check of nvec < minvec for nvec returned from platform_irq_count() will not detect a negative error code in nvec.

This is because minvec is unsigned, and, as such, nvec is promoted to unsigned in that check, which will make it a huge number (if it contained -EPROBE_DEFER).

Quoted 8 lines

In practice, an error should not occur in nvec for the only in-tree user, but add a check anyway.

Fixes e15f2fa959f2 ("driver core: platform: Add devm_platform_get_irqs_affinity()")

---
I hope that this can go through either irqchip or driver/core trees, thanks!

I'll take it, thanks.

greg k-h

author
#3 lore raw
Quoted 11 lines · Greg KH
Quoted 10 lines · John Garry

The current check of nvec < minvec for nvec returned from platform_irq_count() will not detect a negative error code in nvec.

This is because minvec is unsigned, and, as such, nvec is promoted to unsigned in that check, which will make it a huge number (if it contained -EPROBE_DEFER).

In practice, an error should not occur in nvec for the only in-tree user, but add a check anyway.

Quoted 8 lines
Quoted 5 lines
Fixes e15f2fa959f2 ("driver core: platform: Add devm_platform_get_irqs_affinity()")

---
I hope that this can go through either irqchip or driver/core trees, thanks!

I'll take it, thanks.

Hi Greg,

I think that Marc already has taken it:

https://lore.kernel.org/lkml/X%2Fh9vy%[email protected]/T/#m95ef1736dbbd801cd85a4144c8f13c2afe33bc2c

I hope it doesn't cause hassle.

Thanks,
John

#4 lore raw
Quoted 21 lines · John Garry
Quoted 11 lines · Greg KH
Quoted 10 lines · John Garry

The current check of nvec < minvec for nvec returned from platform_irq_count() will not detect a negative error code in nvec.

This is because minvec is unsigned, and, as such, nvec is promoted to unsigned in that check, which will make it a huge number (if it contained -EPROBE_DEFER).

In practice, an error should not occur in nvec for the only in-tree user, but add a check anyway.

Quoted 8 lines
Quoted 5 lines
Fixes e15f2fa959f2 ("driver core: platform: Add devm_platform_get_irqs_affinity()")

---
I hope that this can go through either irqchip or driver/core trees, thanks!

I'll take it, thanks.

Quoted 7 lines

Hi Greg,

I think that Marc already has taken it:

https://lore.kernel.org/lkml/X%2Fh9vy%[email protected]/T/#m95ef1736dbbd801cd85a4144c8f13c2afe33bc2c

I hope it doesn't cause hassle.

I was about to send tglx a pull request.

Greg, let me know if you want me to drop it.

Thanks,

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
maintainer
#5 lore raw
Quoted 29 lines · Marc Zyngier
Quoted 28 lines · John Garry
Quoted 20 lines · Greg KH
Quoted 11 lines · John Garry

The current check of nvec < minvec for nvec returned from platform_irq_count() will not detect a negative error code in nvec.

This is because minvec is unsigned, and, as such, nvec is promoted to unsigned in that check, which will make it a huge number (if it contained
-EPROBE_DEFER).

In practice, an error should not occur in nvec for the only in-tree user, but add a check anyway.

Quoted 7 lines
Fixes e15f2fa959f2 ("driver core: platform: Add

devm_platform_get_irqs_affinity()")

---
I hope that this can go through either irqchip or driver/core trees, thanks!

Quoted 2 lines

I'll take it, thanks.

Hi Greg,

I think that Marc already has taken it:

Quoted 7 lines
Quoted 3 lines

https://lore.kernel.org/lkml/X%2Fh9vy%[email protected]/T/#m95ef1736dbbd801cd85a4144c8f13c2afe33bc2c

I hope it doesn't cause hassle.

I was about to send tglx a pull request.

Greg, let me know if you want me to drop it.

Nope, no worries, git will handle this coming in multiple places :)

thanks,

greg k-h