]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
i2c: mux: demux-pinctrl: do not deactivate a master that is not active
authorPeter Rosin <peda@axentia.se>
Wed, 2 Mar 2022 11:22:35 +0000 (12:22 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Apr 2022 07:06:36 +0000 (09:06 +0200)
[ Upstream commit 1a22aabf20adf89cb216f566913196128766f25b ]

Attempting to rollback the activation of the current master when
the current master has not been activated is bad. priv->cur_chan
and priv->cur_adap are both still zeroed out and the rollback
may result in attempts to revert an of changeset that has not been
applied and do result in calls to both del and put the zeroed out
i2c_adapter. Maybe it crashes, or whatever, but it's bad in any
case.

Fixes: e9d1a0a41d44 ("i2c: mux: demux-pinctrl: Fix an error handling path in 'i2c_demux_pinctrl_probe()'")
Signed-off-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/i2c/muxes/i2c-demux-pinctrl.c

index a86c511c29e0e3107551c8d402ac1d1b5a1e5829..c347860b3690f0b1338e1b39e0b4b4625229b100 100644 (file)
@@ -259,7 +259,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
 
        err = device_create_file(&pdev->dev, &dev_attr_available_masters);
        if (err)
-               goto err_rollback;
+               goto err_rollback_activation;
 
        err = device_create_file(&pdev->dev, &dev_attr_current_master);
        if (err)
@@ -269,8 +269,9 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
 
 err_rollback_available:
        device_remove_file(&pdev->dev, &dev_attr_available_masters);
-err_rollback:
+err_rollback_activation:
        i2c_demux_deactivate_master(priv);
+err_rollback:
        for (j = 0; j < i; j++) {
                of_node_put(priv->chan[j].parent_np);
                of_changeset_destroy(&priv->chan[j].chgset);