mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <petkovbb@googlemail.com>
To: Greg KH <gregkh@suse.de>
Cc: stable@kernel.org, Andrew Morton <akpm@linux-foundation.org>,
	Petr Tesarik <ptesarik@suse.cz>,
	linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org,
	Jens Axboe <jens.axboe@oracle.com>, Jan Kara <jack@suse.cz>,
	Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: Re: [PATCH] ide-cd: fix endianity for the error message in cdrom_read_capacity
Date: Wed, 30 Jul 2008 21:12:57 +0200	[thread overview]
Message-ID: <20080730191257.GA1205@gollum.tnic> (raw)
In-Reply-To: <20080730163327.GA23086@suse.de>

On Wed, Jul 30, 2008 at 09:33:28AM -0700, Greg KH wrote:
> On Wed, Jul 30, 2008 at 10:52:50AM +0200, Boris Petkov wrote:
> > On Wed, Jul 30, 2008 at 10:18 AM, Andrew Morton
> > <akpm@linux-foundation.org> wrote:
> > > On Wed, 30 Jul 2008 10:10:06 +0200 Petr Tesarik <ptesarik@suse.cz> wrote:
> > >
> > >> Resent because of a typo in the LKML address. :(
> > >
> > > Thanks.
> > >
> > >>
> > >> Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667
> > >> still leaves a bug in the error message, because it uses the unconverted
> > >> big-endian value for printk.
> > >>
> > >> Fix this by using a local variable in machine byte order. The result is
> > >> correct, more readable, and also produces slightly shorter code on i386.
> > >>
> > >> Cc: Jens Axboe <jens.axboe@oracle.com>
> > >> Cc: Jan Kara <jack@suse.cz>
> > >> Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
> > 
> > I definitely like this one better, thanks.
> > 
> > Acked-by: Borislav Petkov <petkovbb@gmail.com>
> > 
> > 
> > >
> > > Bart owns this patch now.  It got lost for a month and it has already
> > > been fixed twice and it is also on the route to 2.6.25.x and 2.6.26.x,
> > > so it'll get complicated.  Not a happy little patch.
> > 
> > Greg, can you please apply this one on top of -stable.
> 
> What one?  Do you have a git commit id?

Oh, sorry about that. Ok, you should have in both 2.6.25 and .26 the patch with
upstream commit id e8e7b9eb11c34ee18bde8b7011af41938d1ad667. I rediffed the new
one on top, here's the 2.6.26 version, the 2.6.25 one follows.

--
From: Petr Tesarik <ptesarik@suse.cz>

Aesthetic regards aside, commit e8e7b9eb11c34ee18bde8b7011af41938d1ad667
still leaves a bug in the error message, because it uses the unconverted
big-endian value for printk.

Fix this by using a local variable in machine byte order. The result is
correct, more readable, and also produces slightly shorter code on i386.

Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
Acked-by: Borislav Petkov <petkovbb@gmail.com>
---
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 0cc854e..59875bb 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -1298,6 +1298,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
 
 	int stat;
 	struct request req;
+	__u32 blocklen;
 
 	ide_cd_init_rq(drive, &req);
 
@@ -1314,23 +1315,24 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
 	/*
 	 * Sanity check the given block size
 	 */
-	switch (capbuf.blocklen) {
-	case __constant_cpu_to_be32(512):
-	case __constant_cpu_to_be32(1024):
-	case __constant_cpu_to_be32(2048):
-	case __constant_cpu_to_be32(4096):
+	blocklen = be32_to_cpu(capbuf.blocklen);
+	switch (blocklen) {
+	case 512:
+	case 1024:
+	case 2048:
+	case 4096:
 		break;
 	default:
 		printk(KERN_ERR "%s: weird block size %u\n",
-			drive->name, capbuf.blocklen);
+			drive->name, blocklen);
 		printk(KERN_ERR "%s: default to 2kb block size\n",
 			drive->name);
-		capbuf.blocklen = __constant_cpu_to_be32(2048);
+		blocklen = 2048;
 		break;
 	}
 
 	*capacity = 1 + be32_to_cpu(capbuf.lba);
-	*sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS;
+	*sectors_per_frame = blocklen >> SECTOR_BITS;
 	return 0;
 }
 


-- 
Regards/Gruß,
    Boris.

  reply	other threads:[~2008-07-30 19:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-30  8:10 Petr Tesarik
2008-07-30  8:18 ` Andrew Morton
2008-07-30  8:52   ` Boris Petkov
2008-07-30 16:33     ` Greg KH
2008-07-30 19:12       ` Borislav Petkov [this message]
2008-07-30 20:58         ` Greg KH
2008-07-31  3:32           ` Borislav Petkov
2008-07-30 19:27       ` Borislav Petkov
2008-07-30 19:25     ` Bartlomiej Zolnierkiewicz
2008-07-30 20:02       ` Andrew Morton
2008-07-30 21:23         ` Bartlomiej Zolnierkiewicz

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=20080730191257.GA1205@gollum.tnic \
    --to=petkovbb@googlemail.com \
    --cc=akpm@linux-foundation.org \
    --cc=bzolnier@gmail.com \
    --cc=gregkh@suse.de \
    --cc=jack@suse.cz \
    --cc=jens.axboe@oracle.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=petkovbb@gmail.com \
    --cc=ptesarik@suse.cz \
    --cc=stable@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

all inboxes | Powered by JetHome®