From owner-svn-src-head@FreeBSD.ORG Fri Jul 10 17:42:53 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA216106566B; Fri, 10 Jul 2009 17:42:53 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ADE8C8FC08; Fri, 10 Jul 2009 17:42:53 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n6AHgrjq027297; Fri, 10 Jul 2009 17:42:53 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n6AHgrvQ027295; Fri, 10 Jul 2009 17:42:53 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <200907101742.n6AHgrvQ027295@svn.freebsd.org> From: Scott Long Date: Fri, 10 Jul 2009 17:42:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195573 - head/sbin/camcontrol X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jul 2009 17:42:54 -0000 Author: scottl Date: Fri Jul 10 17:42:53 2009 New Revision: 195573 URL: http://svn.freebsd.org/changeset/base/195573 Log: Fix alignment issue with ATA IDENTIFY structure. Approved by: re Modified: head/sbin/camcontrol/camcontrol.c Modified: head/sbin/camcontrol/camcontrol.c ============================================================================== --- head/sbin/camcontrol/camcontrol.c Fri Jul 10 17:22:41 2009 (r195572) +++ head/sbin/camcontrol/camcontrol.c Fri Jul 10 17:42:53 2009 (r195573) @@ -1121,7 +1121,7 @@ ataidentify(struct cam_device *device, i { union ccb *ccb; struct ata_params *ident_buf; - int error = 0; + u_int i, error = 0; int16_t *ptr; ccb = cam_getccb(device); @@ -1135,22 +1135,21 @@ ataidentify(struct cam_device *device, i bzero(&(&ccb->ccb_h)[1], sizeof(struct ccb_ataio) - sizeof(struct ccb_hdr)); - ident_buf = (struct ata_params *)malloc( - sizeof(struct ata_params)); + ptr = (uint16_t *)malloc(sizeof(struct ata_params)); - if (ident_buf == NULL) { + if (ptr == NULL) { cam_freeccb(ccb); warnx("can't malloc memory for identify\n"); return(1); } - bzero(ident_buf, sizeof(*ident_buf)); + bzero(ptr, sizeof(struct ata_params)); cam_fill_ataio(&ccb->ataio, retry_count, NULL, /*flags*/CAM_DIR_IN, MSG_SIMPLE_Q_TAG, - /*data_ptr*/(u_int8_t *)ident_buf, + /*data_ptr*/(u_int8_t *)ptr, /*dxfer_len*/sizeof(struct ata_params), timeout ? timeout : 30 * 1000); // if (periph->path->device->protocol == PROTO_ATA) @@ -1172,6 +1171,7 @@ ataidentify(struct cam_device *device, i CAM_EPF_ALL, stderr); } + free(ptr); cam_freeccb(ccb); return(1); } @@ -1188,14 +1188,14 @@ ataidentify(struct cam_device *device, i cam_freeccb(ccb); if (error != 0) { - free(ident_buf); + free(ptr); return(error); } - for (ptr = (int16_t *)ident_buf; - ptr < (int16_t *)ident_buf + sizeof(struct ata_params)/2; ptr++) { - *ptr = le16toh(*ptr); - } + for (i = 0; i < sizeof(struct ata_params) / 2; i++) + ptr[i] = le16toh(ptr[i]); + ident_buf = (struct ata_params *)ptr; + if (strncmp(ident_buf->model, "FX", 2) && strncmp(ident_buf->model, "NEC", 3) && strncmp(ident_buf->model, "Pioneer", 7) &&