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 C5C731ED4F for ; Tue, 25 Jul 2023 11:47:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4888EC433C7; Tue, 25 Jul 2023 11:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690285623; bh=qL9Uyi9pDKrhsv0aiOU4si2VGrBEwrbmoVX1Pq1w2/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aBRUaLPdCkQ2kQMA8LXBQS727jW6/l090kxOn2kNmFB0M+vhNo3vO2xhVLD6AVn5R DczqSaxLHHm9zoGtiGpxJjLBwKXFpJ6b9CSHZrUfQLy+Wnin02ImZB1P6nVDi6HCzE ipsX4Ng0eKjgLV+QYgy7aMeJbwQAf28EHfqcipUk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nilesh Javali , Himanshu Madhani , "Martin K. Petersen" Subject: [PATCH 5.4 271/313] scsi: qla2xxx: Check valid rport returned by fc_bsg_to_rport() Date: Tue, 25 Jul 2023 12:47:04 +0200 Message-ID: <20230725104532.790789256@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725104521.167250627@linuxfoundation.org> References: <20230725104521.167250627@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: Nilesh Javali commit af73f23a27206ffb3c477cac75b5fcf03410556e upstream. Klocwork reported warning of rport maybe NULL and will be dereferenced. rport returned by call to fc_bsg_to_rport() could be NULL and dereferenced. Check valid rport returned by fc_bsg_to_rport(). Cc: stable@vger.kernel.org Signed-off-by: Nilesh Javali Link: https://lore.kernel.org/r/20230607113843.37185-5-njavali@marvell.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/qla2xxx/qla_bsg.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -259,6 +259,10 @@ qla2x00_process_els(struct bsg_job *bsg_ if (bsg_request->msgcode == FC_BSG_RPT_ELS) { rport = fc_bsg_to_rport(bsg_job); + if (!rport) { + rval = -ENOMEM; + goto done; + } fcport = *(fc_port_t **) rport->dd_data; host = rport_to_shost(rport); vha = shost_priv(host);