From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A49F92E041E; Tue, 15 Jul 2025 13:49:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752587347; cv=none; b=mbPS/e026/zAkZakE9FbA3oXO1y7ktPMbDXbrPExlsMjLBP2ScBLKq0L9F44t4BUL01JWmAoezUORlwUBepaCYfpwqwFvFRLCU121ryBCB5BImmPnsUFoaBTi/cfD/CMdQe02UNsG7ItsDFKtSHiRMxVVkD6mNd8JQQL+kE7msQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752587347; c=relaxed/simple; bh=0mt7s2vfPyT5zuQJ0eGA30rIQCam/wE5V5ZK6atnBX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xio68Teq3iCq4vBYBDVJ7KCC3hxKSN+YQO6OiTrdyBrk+eOzYScEky5P6awwANNdiJ8WgeYomz+Xa3F0/946ER4ELloV9V9mZbI6xVnk7YbRZ8fs9oJ0R2QE3/ew3hwLLoMusceDboGY6QhglwzZMZ1ZMCBZN1h1v6hCEpNUmGY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wPs2T/Q0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wPs2T/Q0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 360F3C4CEE3; Tue, 15 Jul 2025 13:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1752587347; bh=0mt7s2vfPyT5zuQJ0eGA30rIQCam/wE5V5ZK6atnBX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wPs2T/Q0mrv54mK6wySFKaBQ5BX2soXhf8h/EwHiKgn6OoXJoellMEwQ1r9fZvQ+x /kwZg1iAvasccMK47mp28I4vBJDaIBe8wwmpZPx9H6z2C2n/PQYi2EzbZ4ZgJJGoqS yC1i3WDW+lCNa54wbt2KdOnEQ1l+b/gS+srbzMOk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Subject: [PATCH 6.1 39/88] pwm: mediatek: Ensure to disable clocks in error path Date: Tue, 15 Jul 2025 15:14:15 +0200 Message-ID: <20250715130756.091153581@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250715130754.497128560@linuxfoundation.org> References: <20250715130754.497128560@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Uwe Kleine-König commit 505b730ede7f5c4083ff212aa955155b5b92e574 upstream. After enabling the clocks each error path must disable the clocks again. One of them failed to do so. Unify the error paths to use goto to make it harder for future changes to add a similar bug. Fixes: 7ca59947b5fc ("pwm: mediatek: Prevent divide-by-zero in pwm_mediatek_config()") Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/20250704172728.626815-2-u.kleine-koenig@baylibre.com Cc: stable@vger.kernel.org [ukleinek: backported to 6.6.y] Signed-off-by: Uwe Kleine-König Signed-off-by: Greg Kroah-Hartman --- drivers/pwm/pwm-mediatek.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/drivers/pwm/pwm-mediatek.c +++ b/drivers/pwm/pwm-mediatek.c @@ -129,8 +129,10 @@ static int pwm_mediatek_config(struct pw return ret; clk_rate = clk_get_rate(pc->clk_pwms[pwm->hwpwm]); - if (!clk_rate) - return -EINVAL; + if (!clk_rate) { + ret = -EINVAL; + goto out; + } /* Make sure we use the bus clock and not the 26MHz clock */ if (pc->soc->has_ck_26m_sel) @@ -149,9 +151,9 @@ static int pwm_mediatek_config(struct pw } if (clkdiv > PWM_CLK_DIV_MAX) { - pwm_mediatek_clk_disable(chip, pwm); dev_err(chip->dev, "period of %d ns not supported\n", period_ns); - return -EINVAL; + ret = -EINVAL; + goto out; } if (pc->soc->pwm45_fixup && pwm->hwpwm > 2) { @@ -168,9 +170,10 @@ static int pwm_mediatek_config(struct pw pwm_mediatek_writel(pc, pwm->hwpwm, reg_width, cnt_period); pwm_mediatek_writel(pc, pwm->hwpwm, reg_thres, cnt_duty); +out: pwm_mediatek_clk_disable(chip, pwm); - return 0; + return ret; } static int pwm_mediatek_enable(struct pwm_chip *chip, struct pwm_device *pwm)