mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 18/22] video: Rockchip: fix zero division in rk3588_calc_cru_cfg
Date: Fri, 14 Mar 2025 17:03:08 +0100	[thread overview]
Message-ID: <Z9RTPKnmYeif2qKx@pengutronix.de> (raw)
In-Reply-To: <20250313073445.764875-19-a.fatoum@pengutronix.de>

On Thu, Mar 13, 2025 at 08:34:41AM +0100, Ahmad Fatoum wrote:
> This was detected by clang-analyzer and I don't understand how that
> function could have ever worked, because it's running into the zero
> division in the "successful" code path.

The driver is only tested on rk3568, so this code path likely never
executed.

sascha

> 
> Peeking at rk3568_set_intf_mux, the CRTC clock is passed by the caller
> in barebox, so let's do the same for rk3588_calc_cru_cfg.
> 
> Fixes: c8c0833beb77 ("video: Rockchip: Add VOP2 driver")
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/video/rockchip/rockchip_drm_vop2.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/video/rockchip/rockchip_drm_vop2.c b/drivers/video/rockchip/rockchip_drm_vop2.c
> index 3a1c951ec7e4..f15ef1b57bf5 100644
> --- a/drivers/video/rockchip/rockchip_drm_vop2.c
> +++ b/drivers/video/rockchip/rockchip_drm_vop2.c
> @@ -743,10 +743,10 @@ static unsigned long rk3588_calc_dclk(unsigned long child_clk, unsigned long max
>   */
>  static unsigned long rk3588_calc_cru_cfg(struct vop2_video_port *vp, int id,
>  					 int *dclk_core_div, int *dclk_out_div,
> -					 int *if_pixclk_div, int *if_dclk_div)
> +					 int *if_pixclk_div, int *if_dclk_div,
> +					 u32 crtc_clock)
>  {
>  	struct vop2 *vop2 = vp->vop2;
> -	u32 crtc_clock = 0;
>  	unsigned long v_pixclk = crtc_clock * 1000LL; /* video timing pixclk */
>  	unsigned long dclk_core_rate = v_pixclk >> 2;
>  	unsigned long dclk_rate = v_pixclk;
> @@ -856,7 +856,7 @@ static unsigned long rk3588_set_intf_mux(struct vop2_video_port *vp, int id, u32
>  	u32 die, dip, div, vp_clk_div, val;
>  
>  	clock = rk3588_calc_cru_cfg(vp, id, &dclk_core_div, &dclk_out_div,
> -				    &if_pixclk_div, &if_dclk_div);
> +				    &if_pixclk_div, &if_dclk_div, clock);
>  	if (!clock)
>  		return 0;
>  
> -- 
> 2.39.5
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  parent reply	other threads:[~2025-03-14 16:08 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-13  7:34 [PATCH 00/22] add support for clang-analyzer with scan-build Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 01/22] kbuild: " Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 02/22] soc: ti: k3-navss-ringacc: fix COMPILE_TEST link error Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 03/22] treewide: fix missing headers in sandbox allyesconfig Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 04/22] drivers: don't cast pointer directly to enum Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 05/22] firmware: arm_scmi: smc: compile only for ARM Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 06/22] video: stm32-ltdc: fix printing uninitialized variable Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 07/22] usb: core: remove unnecessary comparison Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 08/22] ddr_spd: fix always true sub-condition Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 09/22] hush: fix make_string behavior on empty strings Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 10/22] nvmem: fix clang-analyzer false-positive use of uninitialized value Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 11/22] string: initialize string array in string selftest Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 12/22] commands: ubsan: hide zero division in test Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 13/22] crypto: ecc: fix clang-analyzer warning about NULL dereference Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 14/22] mci_spi: fix possible use of uninitialized variable Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 15/22] mtd: have mtd_read populate retlen always Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 16/22] of: fdt: silence possible static analyzer false positive Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 17/22] ubi: workaround zero division on malformed input in ubi_assert Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 18/22] video: Rockchip: fix zero division in rk3588_calc_cru_cfg Ahmad Fatoum
2025-03-13  8:09   ` [PATCH] fixup! " Ahmad Fatoum
2025-03-14 16:03   ` Sascha Hauer [this message]
2025-03-13  7:34 ` [PATCH 19/22] lib: scatterlist: don't assert last element for empty sglist Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 20/22] scripts: omap3-usb-loader: fix clang-analyzer false-positive Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 21/22] clk: analogbits: wrpll-cln28hpc: bail out before zero division Ahmad Fatoum
2025-03-13  7:34 ` [PATCH 22/22] watchdog: stm32_iwdg: " Ahmad Fatoum
2025-03-14 16:04 ` [PATCH 00/22] add support for clang-analyzer with scan-build Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z9RTPKnmYeif2qKx@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox