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 CDF6F2F24 for ; Mon, 24 Jun 2024 16:48:14 +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=1719247694; cv=none; b=XyiC8BQVktVwk7H4BOSIRoRxMPyJJUWMqa35VWlmrZntwLFZmcXz32HHcX70cd5fyq9UkQCFs1rKb5CyZyqRsRKJpEndnmmhd5Yfh4MGw8Qapsf50CWo9c1e3D0NARRo84llOokDXw3Q4nmcuBb8xf2DqC65amzf/5qvn9EJFtU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719247694; c=relaxed/simple; bh=To3zCBHaC180yvyMkkT5tFwG+UJB5SkWSKmsGliIUqQ=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=N6m7hyIr+Z+VMflQOoOcaJN99Q6axQcsuZfdO4PcHRRa0o2Y0CisN4DPG7oyWKYsPpnhIGiUjfi5aRayYVOm4k2xy0lR6sEUW8oDEFecJq+Qnvw6cDJFqbgEqCIvciPhIIUKkqYKDWt9KO+m/+NZzGymjiGw8oQAcRnvIFkYBCM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CxMHsZrp; 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="CxMHsZrp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 540A1C2BBFC; Mon, 24 Jun 2024 16:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1719247694; bh=To3zCBHaC180yvyMkkT5tFwG+UJB5SkWSKmsGliIUqQ=; h=Subject:To:Cc:From:Date:From; b=CxMHsZrpyYrwLVj/X/DspDwVE+N8iC9EKcmuAj9zft1gDqTfUKWtsBUTCbF3EvAPg y4rjsC2BROL5gp4b1HP+pEUyhVAnxvCwlngz8Yz5UhU+oTVnOb0GcAjCKbxW63tPyk g2mWk6eGnWGtSVgw3lSyk2bBmErkQG/fC5/yipC4= Subject: FAILED: patch "[PATCH] pwm: stm32: Refuse too small period requests" failed to apply to 5.4-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: <2024062458-try-bouncing-bb82@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.4-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.4.y git checkout FETCH_HEAD git cherry-pick -x c45fcf46ca2368dafe7e5c513a711a6f0f974308 # git commit -s git send-email --to '' --in-reply-to '2024062458-try-bouncing-bb82@gregkh' --subject-prefix 'PATCH 5.4.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