From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 209821773D for ; Wed, 9 Aug 2023 11:19:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98138C433C9; Wed, 9 Aug 2023 11:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1691579971; bh=WtKNUTnezfkSbfJ4V4TtCmVJHKtCpfEKxGuArO3BQDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UluMz2srOekhMP/q3I/h2k+MbGnqVf5xSgMsBPVvSnglECZwT5bZKx6ApQWQ2+26E tF8GZDqHILvEnZ618Fz8Y28GpZeq/Zz+xC1B2DdMjM5HAankg2OHBx97vJJhJjmsYc +irk6AJqO8s6qws4RVTnXJzYBiGTv478Jm9gDI2I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bikash Hazarika , Nilesh Javali , Himanshu Madhani , "Martin K. Petersen" Subject: [PATCH 4.19 182/323] scsi: qla2xxx: Fix potential NULL pointer dereference Date: Wed, 9 Aug 2023 12:40:20 +0200 Message-ID: <20230809103706.488947533@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230809103658.104386911@linuxfoundation.org> References: <20230809103658.104386911@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Bikash Hazarika commit 464ea494a40c6e3e0e8f91dd325408aaf21515ba upstream. Klocwork tool reported 'cur_dsd' may be dereferenced. Add fix to validate pointer before dereferencing the pointer. Cc: stable@vger.kernel.org Signed-off-by: Bikash Hazarika Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20230607113843.37185-3-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_iocb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -603,7 +603,8 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *s *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_6); /* No data transfer */ - if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { + if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE || + tot_dsds == 0) { cmd_pkt->byte_count = cpu_to_le32(0); return 0; }