From: akpm@linux-foundation.org Subject: [patch 03/26] drivers/scsi/lpfc/lpfc_vport.c: fix read buffer overflow Date: Mon, 24 May 2010 12:22:21 -0700 Message-ID: <201005241922.o4OJMLJO011287@imap1.linux-foundation.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Return-path: Received: from smtp1.linux-foundation.org ([140.211.169.13]:49033 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756375Ab0EXTWa (ORCPT ); Mon, 24 May 2010 15:22:30 -0400 Sender: linux-scsi-owner@vger.kernel.org List-Id: linux-scsi@vger.kernel.org To: James.Bottomley@HansenPartnership.com Cc: linux-scsi@vger.kernel.org, akpm@linux-foundation.org, roel.kluin@gmail.com, James.Smart@Emulex.Com, jeykholt@cisco.com From: Roel Kluin Check whether index is within bounds before testing the element. Signed-off-by: Roel Kluin Cc: James Smart Cc: Joe Eykholt Cc: James Bottomley Signed-off-by: Andrew Morton --- drivers/scsi/lpfc/lpfc_vport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff -puN drivers/scsi/lpfc/lpfc_vport.c~drivers-scsi-lpfc-lpfc_vportc-fix-read-buffer-overflow drivers/scsi/lpfc/lpfc_vport.c --- a/drivers/scsi/lpfc/lpfc_vport.c~drivers-scsi-lpfc-lpfc_vportc-fix-read-buffer-overflow +++ a/drivers/scsi/lpfc/lpfc_vport.c @@ -782,7 +782,7 @@ lpfc_destroy_vport_work_array(struct lpf int i; if (vports == NULL) return; - for (i = 0; vports[i] != NULL && i <= phba->max_vports; i++) + for (i = 0; i <= phba->max_vports && vports[i] != NULL; i++) scsi_host_put(lpfc_shost_from_vport(vports[i])); kfree(vports); } _