Skip to contentSkip to conversation

drm/bridge: sii902x: fix comparision of u32 with less than zero

PATCH Applied Colin King 3 participants 5 messages Jun 3, 2019 – Jun 7, 2019

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drm/bridge: sii902x: fix comparision of u32 with less than zero

From: Colin Ian King <[email protected]>

The less than check for the variable num_lanes is always going to be false because the variable is a u32. Fix this by making num_lanes an int and also make loop index i an int too.

Addresses-Coverity: ("Unsigned compared against 0")

Fixes ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
---
 drivers/gpu/drm/bridge/sii902x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/sii902x.c +1 -1
index d6f98d388ac2..21a947603c88 100644
@@ -719,7 +719,7 @@ static int sii902x_audio_codec_init(struct sii902x *sii902x,
 		.max_i2s_channels = 0,
 	};
 	u8 lanes[4];
-	u32 num_lanes, i;
+	int num_lanes, i;
 
 	if (!of_property_read_bool(dev->of_node, "#sound-dai-cells")) {
 		dev_dbg(dev, "%s: No \"#sound-dai-cells\", no audio\n",
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Colin King

From: Colin Ian King <[email protected]>

The less than check for the variable num_lanes is always going to be false because the variable is a u32. Fix this by making num_lanes an int and also make loop index i an int too.

Addresses-Coverity: ("Unsigned compared against 0")

Fixes ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")

Oh, one of these slipped trough after all.

Quoted 18 lines
---
 drivers/gpu/drm/bridge/sii902x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/sii902x.c +1 -1
index d6f98d388ac2..21a947603c88 100644
@@ -719,7 +719,7 @@ static int sii902x_audio_codec_init(struct sii902x *sii902x,
 		.max_i2s_channels = 0,
 	};
 	u8 lanes[4];
-	u32 num_lanes, i;
+	int num_lanes, i;
 
 	if (!of_property_read_bool(dev->of_node, "#sound-dai-cells")) {
 		dev_dbg(dev, "%s: No \"#sound-dai-cells\", no audio\n",
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Reviewed-by on v1 1/1
#2 lore raw
In reply to Colin King
Quoted 7 lines · Colin King

From: Colin Ian King <[email protected]>

The less than check for the variable num_lanes is always going to be false because the variable is a u32. Fix this by making num_lanes an int and also make loop index i an int too.

Addresses-Coverity: ("Unsigned compared against 0")

Is there a rule in Kernel of adding such tags?

I have spotted only: Addresses-Coverity-ID?

Beside this:

 --
Regards
Andrzej

Quoted 19 lines
Fixes ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
---
 drivers/gpu/drm/bridge/sii902x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/sii902x.c +1 -1
index d6f98d388ac2..21a947603c88 100644
@@ -719,7 +719,7 @@ static int sii902x_audio_codec_init(struct sii902x *sii902x,
 		.max_i2s_channels = 0,
 	};
 	u8 lanes[4];
-	u32 num_lanes, i;
+	int num_lanes, i;
 
 	if (!of_property_read_bool(dev->of_node, "#sound-dai-cells")) {
 		dev_dbg(dev, "%s: No \"#sound-dai-cells\", no audio\n",
#3 lore raw
Quoted 7 lines · Andrzej Hajda
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

The less than check for the variable num_lanes is always going to be false because the variable is a u32. Fix this by making num_lanes an int and also make loop index i an int too.

Quoted 7 lines
Quoted 1 line

Addresses-Coverity: ("Unsigned compared against 0")

Is there a rule in Kernel of adding such tags?

I have spotted only: Addresses-Coverity-ID?

Unfortunately I'm running a Coverity in-house and so the Coverity ID is not public, so it does not make sense for me to report the ID.

Colin

Quoted 31 lines

Beside this:

 --
Regards
Andrzej

Quoted 19 lines
Fixes ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
---
 drivers/gpu/drm/bridge/sii902x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/sii902x.c +1 -1
index d6f98d388ac2..21a947603c88 100644
@@ -719,7 +719,7 @@ static int sii902x_audio_codec_init(struct sii902x *sii902x,
 		.max_i2s_channels = 0,
 	};
 	u8 lanes[4];
-	u32 num_lanes, i;
+	int num_lanes, i;
 
 	if (!of_property_read_bool(dev->of_node, "#sound-dai-cells")) {
 		dev_dbg(dev, "%s: No \"#sound-dai-cells\", no audio\n",
#4 lore raw
In reply to Colin King
Quoted 18 lines · Colin King

From: Colin Ian King <[email protected]>

The less than check for the variable num_lanes is always going to be false because the variable is a u32. Fix this by making num_lanes an int and also make loop index i an int too.

Addresses-Coverity: ("Unsigned compared against 0")

Fixes ff5781634c41 ("drm/bridge: sii902x: Implement HDMI audio support")
---
 drivers/gpu/drm/bridge/sii902x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/sii902x.c +0 -0
index d6f98d388ac2..21a947603c88 100644

drivers/gpu/drm/bridge/sii902x.c static int sii902x_audio_codec_init(struct sii902x *sii902x, · line 725

Quoted 8 lines
drivers/gpu/drm/bridge/sii902x.c +1 -1
@@ -719,7 +719,7 @@ static int sii902x_audio_codec_init(struct sii902x *sii902x,
 		.max_i2s_channels = 0,
 	};
 	u8 lanes[4];
-	u32 num_lanes, i;
+	int num_lanes, i;
 
 	if (!of_property_read_bool(dev->of_node, "#sound-dai-cells")) {
 		dev_dbg(dev, "%s: No \"#sound-dai-cells\", no audio\n",

Queued to drm-misc-next.

--
Regards
Andrzej