From: Yang Zi <2959243019@qq.com>
To: dlemoal@kernel.org, cassel@kernel.org, linux-ide@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] ata: pata_pdc2027x: fix division by zero in pdc_adjust_pll
Date: Tue, 25 Aug 2026 16:32:26 +0800 [thread overview]
Message-ID: <tencent_FA2F5F31DC5009EFE7B38D19D754AA6C4507@qq.com> (raw)
pdc_adjust_pll() divides pout_required by pll_clock_khz before checking
that pll_clock_khz is within the valid range. If the PLL input clock is
less than 1000 Hz, pll_clock_khz is 0 and the division triggers a
divide-by-zero error.
Move the sanity check ahead of the division so the invalid input is
rejected before the ratio is computed.
Signed-off-by: Yang Zi <2959243019@qq.com>
---
diff --git a/drivers/ata/pata_pdc2027x.c b/drivers/ata/pata_pdc2027x.c
index d1d1cfb22e27..c4cff4eafbe8 100644
--- a/drivers/ata/pata_pdc2027x.c
+++ b/drivers/ata/pata_pdc2027x.c
@@ -517,7 +517,7 @@ static void pdc_adjust_pll(struct ata_host *host, long pll_clock, unsigned int b
u16 pll_ctl;
long pll_clock_khz = pll_clock / 1000;
long pout_required = board_idx? PDC_133_MHZ:PDC_100_MHZ;
- long ratio = pout_required / pll_clock_khz;
+ long ratio;
int F, R;
/* Sanity check */
@@ -527,6 +527,8 @@ static void pdc_adjust_pll(struct ata_host *host, long pll_clock, unsigned int b
return;
}
+ ratio = pout_required / pll_clock_khz;
+
dev_dbg(host->dev, "pout_required is %ld\n", pout_required);
/* Show the current clock value of PLL control register
next reply other threads:[~2026-08-25 8:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 8:32 Yang Zi [this message]
2026-08-28 5:48 ` [PATCH] ata: pata_pdc2027x: fix division by zero in pdc_adjust_pll Damien Le Moal
2026-08-31 7:53 ` Niklas Cassel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_FA2F5F31DC5009EFE7B38D19D754AA6C4507@qq.com \
--to=2959243019@qq.com \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox