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 02F992F24 for ; Mon, 24 Jun 2024 16:48:09 +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=1719247690; cv=none; b=VxK4qkpeCG9kZnsvXOxzydxVDxJ0Piu5Nl6YqEDAk3C8qF7ahzIAYceRKei3GV8KAjHgPINhPAFBjiZR7/5X2YM0IxzZ1gM33V1MBpXLKLB7uVJAU4+LrEAmVDBzgvLl54mmjnpKDmz6pMvaq6ddDVgG5kdwDNYdVMynykXTt7o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719247690; c=relaxed/simple; bh=Aaf7KR8ydxMDqf32AJZNZPWJVdu4XHirBsgPnZ4wRSM=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=vC5Xi0BFfviknNK5HiZ9Y3S8ifScuawGbmMm0MS8IWnNgHsWcYwQPo78j7zQZrmKa69GH7Y0sv2C6lzzU4u0w15hyq2+rf/b4slb8hHBDHjN1gmS5xDUIoO6PnMItzAT7SCaQVpzMMTvaOICz0uC8/gFLDw6R5PokgQLW6e1qOg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=EoCbvIrO; 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="EoCbvIrO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74012C2BBFC; Mon, 24 Jun 2024 16:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1719247689; bh=Aaf7KR8ydxMDqf32AJZNZPWJVdu4XHirBsgPnZ4wRSM=; h=Subject:To:Cc:From:Date:From; b=EoCbvIrO27QO56H5MHBXV2JMSI/u6SFnedHh94WT1UgnkBYKHLG7SaB8zjWgfq28S CvTeKOWo9dSWNXUQYCOeCdGutzAcsy6kc1q7hMmCTW+gJx23q/iVTRKi3h2bpKPgSb t+L86qBX3JB4bivtygZE5W6MAX74sIehnbWx+ZEw= Subject: FAILED: patch "[PATCH] pwm: stm32: Refuse too small period requests" failed to apply to 5.10-stable tree To: u.kleine-koenig@baylibre.com,tgamblin@baylibre.com,ukleinek@kernel.org Cc: From: Date: Mon, 24 Jun 2024 18:47:58 +0200 Message-ID: <2024062457-reversal-unkind-166b@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x c45fcf46ca2368dafe7e5c513a711a6f0f974308 # git commit -s git send-email --to '' --in-reply-to '2024062457-reversal-unkind-166b@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From c45fcf46ca2368dafe7e5c513a711a6f0f974308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 21 Jun 2024 16:37:12 +0200 Subject: [PATCH] pwm: stm32: Refuse too small period requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If period_ns is small, prd might well become 0. Catch that case because otherwise with regmap_write(priv->regmap, TIM_ARR, prd - 1); a few lines down quite a big period is configured. Fixes: 7edf7369205b ("pwm: Add driver for STM32 plaftorm") Cc: stable@vger.kernel.org Reviewed-by: Trevor Gamblin Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/b86f62f099983646f97eeb6bfc0117bb2d0c340d.1718979150.git.u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index a2f231d13a9f..3e7b2a8e34e7 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -337,6 +337,8 @@ static int stm32_pwm_config(struct stm32_pwm *priv, unsigned int ch, prd = mul_u64_u64_div_u64(period_ns, clk_get_rate(priv->clk), (u64)NSEC_PER_SEC * (prescaler + 1)); + if (!prd) + return -EINVAL; /* * All channels share the same prescaler and counter so when two