public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xsysace: Fix dereferencing of cf_id after hd_driveid removal
@ 2009-04-05  8:39 Grant Likely
  2009-04-06 20:58 ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 2+ messages in thread
From: Grant Likely @ 2009-04-05  8:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Grant Likely, Bartlomiej Zolnierkiewicz

From: Grant Likely <grant.likely@secretlab.ca>

Commit 4aaf2fec718f6fbf38668edf733a0ab09a49cab1 (xsysace: make it
'struct hd_driveid'-free) converted the cf_id member of 'struct
ace_device' from a 'struct hd_driveid' to a u16 array.  However,
references to the base of the structure were still using the '&'
operator.  When the address was used with the ata_id_u32() macro, the
compiler used the size of the entire array instead of sizeof(u16) to
calculate the offset from the base address.

This patch removes the use of the '&' operator from all references of
cf_id to fix the bug and remove future confusion.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
CC: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---

 drivers/block/xsysace.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)


diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c
index 6cccdc3..4aecf5d 100644
--- a/drivers/block/xsysace.c
+++ b/drivers/block/xsysace.c
@@ -563,7 +563,7 @@ static void ace_fsm_dostate(struct ace_device *ace)
 	case ACE_FSM_STATE_IDENTIFY_PREPARE:
 		/* Send identify command */
 		ace->fsm_task = ACE_TASK_IDENTIFY;
-		ace->data_ptr = &ace->cf_id;
+		ace->data_ptr = ace->cf_id;
 		ace->data_count = ACE_BUF_PER_SECTOR;
 		ace_out(ace, ACE_SECCNTCMD, ACE_SECCNTCMD_IDENTIFY);
 
@@ -608,8 +608,8 @@ static void ace_fsm_dostate(struct ace_device *ace)
 		break;
 
 	case ACE_FSM_STATE_IDENTIFY_COMPLETE:
-		ace_fix_driveid(&ace->cf_id[0]);
-		ace_dump_mem(&ace->cf_id, 512);	/* Debug: Dump out disk ID */
+		ace_fix_driveid(ace->cf_id);
+		ace_dump_mem(ace->cf_id, 512);	/* Debug: Dump out disk ID */
 
 		if (ace->data_result) {
 			/* Error occured, disable the disk */
@@ -622,9 +622,9 @@ static void ace_fsm_dostate(struct ace_device *ace)
 
 			/* Record disk parameters */
 			set_capacity(ace->gd,
-				ata_id_u32(&ace->cf_id, ATA_ID_LBA_CAPACITY));
+				ata_id_u32(ace->cf_id, ATA_ID_LBA_CAPACITY));
 			dev_info(ace->dev, "capacity: %i sectors\n",
-				ata_id_u32(&ace->cf_id, ATA_ID_LBA_CAPACITY));
+				ata_id_u32(ace->cf_id, ATA_ID_LBA_CAPACITY));
 		}
 
 		/* We're done, drop to IDLE state and notify waiters */
@@ -923,7 +923,7 @@ static int ace_release(struct gendisk *disk, fmode_t mode)
 static int ace_getgeo(struct block_device *bdev, struct hd_geometry *geo)
 {
 	struct ace_device *ace = bdev->bd_disk->private_data;
-	u16 *cf_id = &ace->cf_id[0];
+	u16 *cf_id = ace->cf_id;
 
 	dev_dbg(ace->dev, "ace_getgeo()\n");
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] xsysace: Fix dereferencing of cf_id after hd_driveid removal
  2009-04-05  8:39 [PATCH] xsysace: Fix dereferencing of cf_id after hd_driveid removal Grant Likely
@ 2009-04-06 20:58 ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 2+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-04-06 20:58 UTC (permalink / raw)
  To: Grant Likely; +Cc: linux-kernel

On Sunday 05 April 2009, Grant Likely wrote:
> From: Grant Likely <grant.likely@secretlab.ca>
> 
> Commit 4aaf2fec718f6fbf38668edf733a0ab09a49cab1 (xsysace: make it
> 'struct hd_driveid'-free) converted the cf_id member of 'struct
> ace_device' from a 'struct hd_driveid' to a u16 array.  However,
> references to the base of the structure were still using the '&'
> operator.  When the address was used with the ata_id_u32() macro, the
> compiler used the size of the entire array instead of sizeof(u16) to
> calculate the offset from the base address.
>  
> This patch removes the use of the '&' operator from all references of
> cf_id to fix the bug and remove future confusion.
> 
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> CC: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

Thanks for quickly spotting & fixing it.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-06 21:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-05  8:39 [PATCH] xsysace: Fix dereferencing of cf_id after hd_driveid removal Grant Likely
2009-04-06 20:58 ` Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox