From e1014452af0f36bf09007f4cf5d1b259d544b2f0 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sat, 22 May 2010 09:40:14 -0700 Subject: [PATCH] AHCI - Fix use of error ccb in error path * A conditional was improperly reusing the 'ccb' variable. Use a different variable name so the original ccb (the error ccb) is not replaced. --- sys/dev/disk/ahci/ahci.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/sys/dev/disk/ahci/ahci.c b/sys/dev/disk/ahci/ahci.c index 1b8bf29..a290e06 100644 --- a/sys/dev/disk/ahci/ahci.c +++ b/sys/dev/disk/ahci/ahci.c @@ -2922,6 +2922,7 @@ ahci_port_read_ncq_error(struct ahci_port *ap, int target) { struct ata_log_page_10h *log; struct ahci_ccb *ccb; + struct ahci_ccb *ccb2; struct ahci_cmd_hdr *cmd_slot; struct ata_fis_h2d *fis; int err_slot; @@ -2986,19 +2987,19 @@ ahci_port_read_ncq_error(struct ahci_port *ap, int target) /* Copy back the log record as a D2H register FIS. */ err_slot = log->err_regs.type & ATA_LOG_10H_TYPE_TAG_MASK; - ccb = &ap->ap_ccbs[err_slot]; - if (ccb->ccb_xa.state == ATA_S_ONCHIP) { + ccb2 = &ap->ap_ccbs[err_slot]; + if (ccb2->ccb_xa.state == ATA_S_ONCHIP) { kprintf("%s: read NCQ error page slot=%d\n", - ATANAME(ap, ccb->ccb_xa.at), + ATANAME(ap, ccb2->ccb_xa.at), err_slot); - memcpy(&ccb->ccb_xa.rfis, &log->err_regs, + memcpy(&ccb2->ccb_xa.rfis, &log->err_regs, sizeof(struct ata_fis_d2h)); - ccb->ccb_xa.rfis.type = ATA_FIS_TYPE_D2H; - ccb->ccb_xa.rfis.flags = 0; + ccb2->ccb_xa.rfis.type = ATA_FIS_TYPE_D2H; + ccb2->ccb_xa.rfis.flags = 0; } else { kprintf("%s: read NCQ error page slot=%d, " "slot does not match any cmds\n", - ATANAME(ccb->ccb_port, ccb->ccb_xa.at), + ATANAME(ccb2->ccb_port, ccb2->ccb_xa.at), err_slot); err_slot = -1; } -- 1.7.7.2