All of lore.kernel.org
 help / color / mirror / Atom feed
From: Albert Lee <albertcc@tw.ibm.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	Doug Maxey <dwm@maxeymade.com>,
	Linux IDE <linux-ide@vger.kernel.org>
Subject: [PATCH libata-2.6 3/5] __atapi_pio_bytes() if condition enhancement
Date: Fri, 18 Mar 2005 15:49:39 +0800	[thread overview]
Message-ID: <423A8813.3020507@tw.ibm.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1164 bytes --]

Hi Jeff,

Problem:
   In __atapi_pio_bytes(), when (bytes > qc->nbytes) or (qc->cursg_ofs > sg->length) or
(count > bytes), the condition is not handled properly.

Changes:
- Fix the if condition mentioned above.

   Attached please find the patch against the libata-2.6 tree for your review. Thanks.

Albert

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
---------------------------------------
--- libata-2.6-atapi_pio_bytes/drivers/scsi/libata-core.c	2005-03-18 13:20:01.000000000 +0800
+++ libata-2.6-reorder/drivers/scsi/libata-core.c	2005-03-18 12:56:44.000000000 +0800
@@ -2334,7 +2334,7 @@
  	unsigned char *buf;
  	unsigned int offset, count;

-	if (qc->curbytes == qc->nbytes - bytes)
+	if (qc->curbytes + bytes >= qc->nbytes)
  		ap->pio_task_state = PIO_ST_LAST;

  next_sg:
@@ -2355,11 +2355,10 @@

  	buf = kmap(page) + offset;

-	bytes -= count;
  	qc->curbytes += count;
  	qc->cursg_ofs += count;

-	if (qc->cursg_ofs == sg->length) {
+	if (qc->cursg_ofs >= sg->length) {
  		qc->cursg++;
  		qc->cursg_ofs = 0;
  	}
@@ -2371,7 +2370,9 @@

  	kunmap(page);

-	if (bytes) {
+	if (bytes > count) {
+		bytes -= count;
+
  		goto next_sg;
  	}
  }


[-- Attachment #2: reorder.diff --]
[-- Type: text/plain, Size: 758 bytes --]

--- libata-2.6-atapi_pio_bytes/drivers/scsi/libata-core.c	2005-03-18 13:20:01.000000000 +0800
+++ libata-2.6-reorder/drivers/scsi/libata-core.c	2005-03-18 12:56:44.000000000 +0800
@@ -2334,7 +2334,7 @@
 	unsigned char *buf;
 	unsigned int offset, count;
 
-	if (qc->curbytes == qc->nbytes - bytes)
+	if (qc->curbytes + bytes >= qc->nbytes)
 		ap->pio_task_state = PIO_ST_LAST;
 
 next_sg:
@@ -2355,11 +2355,10 @@
 
 	buf = kmap(page) + offset;
 
-	bytes -= count;
 	qc->curbytes += count;
 	qc->cursg_ofs += count;
 
-	if (qc->cursg_ofs == sg->length) {
+	if (qc->cursg_ofs >= sg->length) {
 		qc->cursg++;
 		qc->cursg_ofs = 0;
 	}
@@ -2371,7 +2370,9 @@
 
 	kunmap(page);
 
-	if (bytes) {
+	if (bytes > count) {
+		bytes -= count;
+
 		goto next_sg;
 	}
 }

                 reply	other threads:[~2005-03-18  7:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=423A8813.3020507@tw.ibm.com \
    --to=albertcc@tw.ibm.com \
    --cc=bzolnier@gmail.com \
    --cc=dwm@maxeymade.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@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 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.