From owner-svn-src-head@FreeBSD.ORG Sat Oct 18 17:11:03 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0AE7A8CF; Sat, 18 Oct 2014 17:11:03 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D1938359; Sat, 18 Oct 2014 17:11:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9IHB2DN048622; Sat, 18 Oct 2014 17:11:02 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9IHB2FF048621; Sat, 18 Oct 2014 17:11:02 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201410181711.s9IHB2FF048621@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 18 Oct 2014 17:11:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273259 - head/sys/cam/ctl X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 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: Sat, 18 Oct 2014 17:11:03 -0000 Author: mav Date: Sat Oct 18 17:11:02 2014 New Revision: 273259 URL: https://svnweb.freebsd.org/changeset/base/273259 Log: Make VPD 80h (Serial Number) transfer length match serial number length. MFC after: 1 week Modified: head/sys/cam/ctl/ctl.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Sat Oct 18 17:00:55 2014 (r273258) +++ head/sys/cam/ctl/ctl.c Sat Oct 18 17:11:02 2014 (r273259) @@ -9705,17 +9705,17 @@ ctl_inquiry_evpd_serial(struct ctl_scsii { struct scsi_vpd_unit_serial_number *sn_ptr; struct ctl_lun *lun; + int data_len; lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; - ctsio->kern_data_ptr = malloc(sizeof(*sn_ptr), M_CTL, M_WAITOK | M_ZERO); + data_len = 4 + CTL_SN_LEN; + ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); sn_ptr = (struct scsi_vpd_unit_serial_number *)ctsio->kern_data_ptr; - ctsio->kern_sg_entries = 0; - - if (sizeof(*sn_ptr) < alloc_len) { - ctsio->residual = alloc_len - sizeof(*sn_ptr); - ctsio->kern_data_len = sizeof(*sn_ptr); - ctsio->kern_total_len = sizeof(*sn_ptr); + if (data_len < alloc_len) { + ctsio->residual = alloc_len - data_len; + ctsio->kern_data_len = data_len; + ctsio->kern_total_len = data_len; } else { ctsio->residual = 0; ctsio->kern_data_len = alloc_len; @@ -9737,16 +9737,16 @@ ctl_inquiry_evpd_serial(struct ctl_scsii sn_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; sn_ptr->page_code = SVPD_UNIT_SERIAL_NUMBER; - sn_ptr->length = ctl_min(sizeof(*sn_ptr) - 4, CTL_SN_LEN); + sn_ptr->length = CTL_SN_LEN; /* * If we don't have a LUN, we just leave the serial number as * all spaces. */ - memset(sn_ptr->serial_num, 0x20, sizeof(sn_ptr->serial_num)); if (lun != NULL) { strncpy((char *)sn_ptr->serial_num, (char *)lun->be_lun->serial_num, CTL_SN_LEN); - } + } else + memset(sn_ptr->serial_num, 0x20, CTL_SN_LEN); ctsio->scsi_status = SCSI_STATUS_OK; ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED;