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 40C482F24 for ; Mon, 24 Jun 2024 16:48:06 +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=1719247687; cv=none; b=gNIf41XI0IIzXDd8GDfHLkY5QNbQqou0p6+2oFxFQZW9nuRFKwFaGof/RueKSY8rQkpFW6zDAb7e2pNXHBLvbfCfVGG2ucODxaZvohdqK7iSbPiz2FoP+M+H75357jyLkRv9EfrMWucTpQn8K7i5Ka9xBql0Yku6SRU1XSqb3+Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719247687; c=relaxed/simple; bh=IhokZv/Gw/LHp8U8FoVJQYWcKkwWXW/4UchXN3hFLpA=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=LOD9//8Wq4zPRZ2y4KJVmIeSBBeJuroWAWPAsazJ2wuGy/QcCAzUC8XMcnh+Qqa/MSKK2262m/P71bjQZJ/JSbzvUq8vpMMxmoIvW1SVH0ZzRwAfe/kIumn6lAv1I9ibBUbx3BbK18kg+lpkU5s59fSXuh3qdQbKIf4JXOTct84= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FfVQ0Afp; 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="FfVQ0Afp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79278C2BBFC; Mon, 24 Jun 2024 16:48:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1719247686; bh=IhokZv/Gw/LHp8U8FoVJQYWcKkwWXW/4UchXN3hFLpA=; h=Subject:To:Cc:From:Date:From; b=FfVQ0AfpikFbDJdwE+tn4s0desnSnTJPK3nDHs9U0pFs/S4d5dphJz0Q1/BV9UVqO vMHpR+GyxZFHnEU7FYmhlQ/kbX4bkvuBaUqcSuK6UTf4lxkHkdShw5Pdmzxgms7I+3 GcnRhMgQylHES5ikCKAuK97FlSS0wC03y/17ggZk= Subject: FAILED: patch "[PATCH] pwm: stm32: Refuse too small period requests" failed to apply to 5.15-stable tree To: u.kleine-koenig@baylibre.com,tgamblin@baylibre.com,ukleinek@kernel.org Cc: From: Date: Mon, 24 Jun 2024 18:47:57 +0200 Message-ID: <2024062457-irritant-squatter-ff51@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.15-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.15.y git checkout FETCH_HEAD git cherry-pick -x c45fcf46ca2368dafe7e5c513a711a6f0f974308 # git commit -s git send-email --to '' --in-reply-to '2024062457-irritant-squatter-ff51@gregkh' --subject-prefix 'PATCH 5.15.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