ALSA: cs4236: fix error return comparison of an unsigned integer
diff mbox series

Message ID 20191122131354.58042-1-colin.king@canonical.com
State New
Headers show
Series
  • ALSA: cs4236: fix error return comparison of an unsigned integer
Related show

Commit Message

Colin Ian King Nov. 22, 2019, 1:13 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The return from pnp_irq is an unsigned integer type resource_size_t
and hence the error check for a positive non-error code is always
going to be true.  A check for a non-failure return from pnp_irq
should in fact be for (resource_size_t)-1 rather than >= 0.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: a9824c868a2c ("[ALSA] Add CS4232 PnP BIOS support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 sound/isa/cs423x/cs4236.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Takashi Iwai Nov. 22, 2019, 1:26 p.m. UTC | #1
On Fri, 22 Nov 2019 14:13:54 +0100,
Colin King wrote:
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> The return from pnp_irq is an unsigned integer type resource_size_t
> and hence the error check for a positive non-error code is always
> going to be true.  A check for a non-failure return from pnp_irq
> should in fact be for (resource_size_t)-1 rather than >= 0.
> 
> Addresses-Coverity: ("Unsigned compared against 0")
> Fixes: a9824c868a2c ("[ALSA] Add CS4232 PnP BIOS support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied, thanks.


Takashi

Patch
diff mbox series

diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
index 78dd213589b4..fa3c39cff5f8 100644
--- a/sound/isa/cs423x/cs4236.c
+++ b/sound/isa/cs423x/cs4236.c
@@ -278,7 +278,8 @@  static int snd_cs423x_pnp_init_mpu(int dev, struct pnp_dev *pdev)
 	} else {
 		mpu_port[dev] = pnp_port_start(pdev, 0);
 		if (mpu_irq[dev] >= 0 &&
-		    pnp_irq_valid(pdev, 0) && pnp_irq(pdev, 0) >= 0) {
+		    pnp_irq_valid(pdev, 0) &&
+		    pnp_irq(pdev, 0) != (resource_size_t)-1) {
 			mpu_irq[dev] = pnp_irq(pdev, 0);
 		} else {
 			mpu_irq[dev] = -1;	/* disable interrupt */