From owner-svn-src-all@FreeBSD.ORG Wed Oct 9 19:26:35 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id DCBD7B5D; Wed, 9 Oct 2013 19:26:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) 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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id AF95D2F3D; Wed, 9 Oct 2013 19:26:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r99JQZrb076713; Wed, 9 Oct 2013 19:26:35 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r99JQZSl076712; Wed, 9 Oct 2013 19:26:35 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201310091926.r99JQZSl076712@svn.freebsd.org> From: Alexander Motin Date: Wed, 9 Oct 2013 19:26:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r256226 - stable/9/sys/cam/scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Oct 2013 19:26:36 -0000 Author: mav Date: Wed Oct 9 19:26:35 2013 New Revision: 256226 URL: http://svnweb.freebsd.org/changeset/base/256226 Log: MFC r255304: Fix kernel panic if cache->nelms is zero. Modified: stable/9/sys/cam/scsi/scsi_enc_ses.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_enc_ses.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_enc_ses.c Wed Oct 9 19:25:22 2013 (r256225) +++ stable/9/sys/cam/scsi/scsi_enc_ses.c Wed Oct 9 19:26:35 2013 (r256226) @@ -567,8 +567,8 @@ ses_cache_free_elm_addlstatus(enc_softc_ return; for (cur_elm = cache->elm_map, - last_elm = &cache->elm_map[cache->nelms - 1]; - cur_elm <= last_elm; cur_elm++) { + last_elm = &cache->elm_map[cache->nelms]; + cur_elm != last_elm; cur_elm++) { ses_element_t *elmpriv; elmpriv = cur_elm->elm_private; @@ -598,8 +598,8 @@ ses_cache_free_elm_descs(enc_softc_t *en return; for (cur_elm = cache->elm_map, - last_elm = &cache->elm_map[cache->nelms - 1]; - cur_elm <= last_elm; cur_elm++) { + last_elm = &cache->elm_map[cache->nelms]; + cur_elm != last_elm; cur_elm++) { ses_element_t *elmpriv; elmpriv = cur_elm->elm_private; @@ -644,8 +644,8 @@ ses_cache_free_elm_map(enc_softc_t *enc, ses_cache_free_elm_descs(enc, cache); ses_cache_free_elm_addlstatus(enc, cache); for (cur_elm = cache->elm_map, - last_elm = &cache->elm_map[cache->nelms - 1]; - cur_elm <= last_elm; cur_elm++) { + last_elm = &cache->elm_map[cache->nelms]; + cur_elm != last_elm; cur_elm++) { ENC_FREE_AND_NULL(cur_elm->elm_private); } @@ -717,8 +717,8 @@ ses_cache_clone(enc_softc_t *enc, enc_ca dst->elm_map = ENC_MALLOCZ(dst->nelms * sizeof(enc_element_t)); memcpy(dst->elm_map, src->elm_map, dst->nelms * sizeof(enc_element_t)); for (dst_elm = dst->elm_map, src_elm = src->elm_map, - last_elm = &src->elm_map[src->nelms - 1]; - src_elm <= last_elm; src_elm++, dst_elm++) { + last_elm = &src->elm_map[src->nelms]; + src_elm != last_elm; src_elm++, dst_elm++) { dst_elm->elm_private = ENC_MALLOCZ(sizeof(ses_element_t)); memcpy(dst_elm->elm_private, src_elm->elm_private,