Skip to contentSkip to conversation

drm/sun4i: hdmi: Fix unitialized variable

PATCH In review Maxime Ripard 2 participants 5 messages Oct 21, 2018 – Oct 29, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/sun4i: hdmi: Fix unitialized variable

The is_double variable is used to store, and possibly returning to the calling function, whether it needs to double the rate of the parent clock or not.

In the case where it does, the variable is affected, but in the case where it doesn't we return some uninitialized value. Fix this.

---
 drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c +1 -1
index 3ecffa52c814..cd2348554bac 100644
@@ -35,7 +35,7 @@ static unsigned long sun4i_tmds_calc_divider(unsigned long rate,
 {
 	unsigned long best_rate = 0;
 	u8 best_m = 0, m;
-	bool is_double;
+	bool is_double = false;
 
 	for (m = div_offset ?: 1; m < (16 + div_offset); m++) {
 		u8 d;
Signature · 1 line
2.19.1
#1 lore raw

PATCH 2/2 drm/sun4i: hdmi: Fix double flag assignation

The is_double flag is a boolean currently assigned to the value of the d variable, that is either 1 or 2. It means that this is_double variable is always set to true, even though the initial intent was to have it set to true when d is 2.

Fix this.

Fixes 9c5681011a0c ("drm/sun4i: Add HDMI support")
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c +1 -1
index cd2348554bac..fb985ba1a176 100644
@@ -52,7 +52,7 @@ static unsigned long sun4i_tmds_calc_divider(unsigned long rate,
 			    (rate - tmp_rate) < (rate - best_rate)) {
 				best_rate = tmp_rate;
 				best_m = m;
-				is_double = d;
+				is_double = (d == 2) ? true : false;
 			}
 		}
 	}
Signature · 1 line
2.19.1
#4 lore raw
In reply to Maxime Ripard

Il 21/10/2018 18:34, Maxime Ripard ha scritto:

Quoted 28 lines

The is_double variable is used to store, and possibly returning to the calling function, whether it needs to double the rate of the parent clock or not.

In the case where it does, the variable is affected, but in the case where it doesn't we return some uninitialized value. Fix this.

Signed-off-by Maxime Ripard <[email protected]: Giulio Benetti <[email protected]>
---
  drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c +1 -1
index 3ecffa52c814..cd2348554bac 100644
@@ -35,7 +35,7 @@ static unsigned long sun4i_tmds_calc_divider(unsigned long rate,
  {
  	unsigned long best_rate = 0;
  	u8 best_m = 0, m;
-	bool is_double;
+	bool is_double = false;
 
  	for (m = div_offset ?: 1; m < (16 + div_offset); m++) {
  		u8 d;
Signature · 14 lines
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale € 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/sun4i: hdmi: Fix double flag assignation

In reply to Maxime Ripard

Il 21/10/2018 18:34, Maxime Ripard ha scritto:

Quoted 10 lines

The is_double flag is a boolean currently assigned to the value of the d variable, that is either 1 or 2. It means that this is_double variable is always set to true, even though the initial intent was to have it set to true when d is 2.

Fix this.

Fixes 9c5681011a0c ("drm/sun4i: Add HDMI support")
Quoted 18 lines
---
  drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c +1 -1
index cd2348554bac..fb985ba1a176 100644
@@ -52,7 +52,7 @@ static unsigned long sun4i_tmds_calc_divider(unsigned long rate,
  			    (rate - tmp_rate) < (rate - best_rate)) {
  				best_rate = tmp_rate;
  				best_m = m;
-				is_double = d;
+				is_double = (d == 2) ? true : false;
  			}
  		}
  	}
Signature · 14 lines
Giulio Benetti
CTO

MICRONOVA SRL
Sede: Via A. Niedda 3 - 35010 Vigonza (PD)
Tel. 049/8931563 - Fax 049/8931346
Cod.Fiscale - P.IVA 02663420285
Capitale Sociale € 26.000 i.v.
Iscritta al Reg. Imprese di Padova N. 02663420285
Numero R.E.A. 258642
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
author Applied
#3 lore raw

Re: [PATCH 2/2] drm/sun4i: hdmi: Fix double flag assignation

Quoted 6 lines · Giulio Benetti

Il 21/10/2018 18:34, Maxime Ripard ha scritto:

Quoted 5 lines

The is_double flag is a boolean currently assigned to the value of the d variable, that is either 1 or 2. It means that this is_double variable is always set to true, even though the initial intent was to have it set to true when d is 2.

Quoted 7 lines
Quoted 5 lines

Fix this.

Fixes 9c5681011a0c ("drm/sun4i: Add HDMI support")

Applied both, thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181029/abda975c/attachment.sig>