mirror of
				https://github.com/smaeul/u-boot.git
				synced 2025-11-04 14:00:19 +00:00 
			
		
		
		
	video: backlight: pwm: avoid integer overflow in duty cycle calculation
The intermediate value could overflow for large periods and levels. Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
		
							parent
							
								
									6a0b888580
								
							
						
					
					
						commit
						533ad9dcda
					
				@ -63,7 +63,7 @@ static int set_pwm(struct pwm_backlight_priv *priv)
 | 
				
			|||||||
	int ret;
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (priv->period_ns) {
 | 
						if (priv->period_ns) {
 | 
				
			||||||
		duty_cycle = priv->period_ns * (priv->cur_level - priv->min_level) /
 | 
							duty_cycle = (u64)priv->period_ns * (priv->cur_level - priv->min_level) /
 | 
				
			||||||
			(priv->max_level - priv->min_level);
 | 
								(priv->max_level - priv->min_level);
 | 
				
			||||||
		ret = pwm_set_config(priv->pwm, priv->channel, priv->period_ns,
 | 
							ret = pwm_set_config(priv->pwm, priv->channel, priv->period_ns,
 | 
				
			||||||
				     duty_cycle);
 | 
									     duty_cycle);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user