Skip to contentSkip to conversation

media: platform: return early if the iface is not handled

PATCH In review [email protected] 2 participants 2 messages Mar 19, 2022 – Apr 5, 2022 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: platform: return early if the iface is not handled

From: Tom Rix <[email protected]>

Clang static analysis reports this issue ispcsiphy.c:63:14: warning: The left operand of '<<'
is a garbage value

        reg |= mode << shift;
               ~~~~ ^

The iface switch-statement default case falls through to ISP_INTERFACE_CCP2B_PHY1. Which is later checked to set the mode. Since the default case is left out of this check mode is never set. Instead of falling through and assuming a ISP_INTERFACE_CCP2B_PHY1 iface, return.

---
 drivers/media/platform/ti/omap3isp/ispcsiphy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/ti/omap3isp/ispcsiphy.c +2 -1
index 6dc7359c5131d..1bde76c0adbee 100644
@@ -31,7 +31,8 @@ static void csiphy_routing_cfg_3630(struct isp_csiphy *phy,
 
 	switch (iface) {
 	default:
-	/* Should not happen in practice, but let's keep the compiler happy. */
+		/* Should not happen in practice, but let's keep the compiler happy. */
+		return;
 	case ISP_INTERFACE_CCP2B_PHY1:
 		reg &= ~OMAP3630_CONTROL_CAMERA_PHY_CTRL_CSI1_RX_SEL_PHY2;
 		shift = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_PHY1_SHIFT;
Signature · 1 line
2.26.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Sat, Mar 19, 2022 at 7:35 AM <[email protected]> wrote:

From: Tom Rix <[email protected]>

Clang static analysis reports this issue ispcsiphy.c:63:14: warning: The left operand of '<<'
is a garbage value

        reg |= mode << shift;
               ~~~~ ^
Quoted 8 lines

The iface switch-statement default case falls through to ISP_INTERFACE_CCP2B_PHY1. Which is later checked to set the mode. Since the default case is left out of this check mode is never set. Instead of falling through and assuming a ISP_INTERFACE_CCP2B_PHY1 iface, return.

Thanks for the patch!

Quoted 21 lines
---
 drivers/media/platform/ti/omap3isp/ispcsiphy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/ti/omap3isp/ispcsiphy.c +2 -2
index 6dc7359c5131d..1bde76c0adbee 100644
@@ -31,7 +31,8 @@ static void csiphy_routing_cfg_3630(struct isp_csiphy *phy,
 
        switch (iface) {
        default:
-       /* Should not happen in practice, but let's keep the compiler happy. */
+               /* Should not happen in practice, but let's keep the compiler happy. */
+               return;
        case ISP_INTERFACE_CCP2B_PHY1:
                reg &= ~OMAP3630_CONTROL_CAMERA_PHY_CTRL_CSI1_RX_SEL_PHY2;
                shift = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_PHY1_SHIFT;
--

2.26.3

Signature · 2 lines
Thanks,
~Nick Desaulniers