From: Alan <gnomes@lxorguk.ukuu.org.uk>
To: tj@kernel.org, linux-ide@vger.kernel.org
Subject: [PATCH] libata: Fix division by zero
Date: Wed, 08 Apr 2015 13:51:36 +0100 [thread overview]
Message-ID: <20150408125114.29925.841.stgit@localhost.localdomain> (raw)
(Coverity 1192289, 1192292, 1192294)
We have several controllers that in some cases use ata_timing_compute but do
not do UDMA. They pass 0 for UT, which ends up with us doing a division by
zero. We could pass some other bogus value in or we could make the libata
code do the sensible thing and treat a UT of 0 as meaning "I'm not asking
about UDMA".
This patches does the latter which is IMHO the more robust option.
Signed-off-by: Alan Cox <alan@linux.intel.com>
---
0 files changed
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index f6cb1f1..6b1bd36 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2966,7 +2966,8 @@ static void ata_timing_quantize(const struct ata_timing *t, struct ata_timing *q
q->recover = EZ(t->recover * 1000, T);
q->dmack_hold = EZ(t->dmack_hold * 1000, T);
q->cycle = EZ(t->cycle * 1000, T);
- q->udma = EZ(t->udma * 1000, UT);
+ if (UT)
+ q->udma = EZ(t->udma * 1000, UT);
}
void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
next reply other threads:[~2015-04-08 12:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 12:51 Alan [this message]
2015-04-08 13:52 ` [PATCH] libata: Fix division by zero Bartlomiej Zolnierkiewicz
2015-04-08 14:03 ` Bartlomiej Zolnierkiewicz
2015-04-08 15:04 ` One Thousand Gnomes
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=20150408125114.29925.841.stgit@localhost.localdomain \
--to=gnomes@lxorguk.ukuu.org.uk \
--cc=linux-ide@vger.kernel.org \
--cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.