Date: Thu, 23 Oct 2014 07:37:49 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r273532 - stable/10/sys/cam/ctl Message-ID: <201410230737.s9N7bnHj073177@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Thu Oct 23 07:37:48 2014 New Revision: 273532 URL: https://svnweb.freebsd.org/changeset/base/273532 Log: MFC r273259: Make VPD 80h (Serial Number) transfer length match serial number length. Modified: stable/10/sys/cam/ctl/ctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl.c ============================================================================== --- stable/10/sys/cam/ctl/ctl.c Thu Oct 23 07:36:33 2014 (r273531) +++ stable/10/sys/cam/ctl/ctl.c Thu Oct 23 07:37:48 2014 (r273532) @@ -9963,17 +9963,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; @@ -9995,16 +9995,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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410230737.s9N7bnHj073177>