From patchwork Mon Nov 21 09:17:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Kosyh X-Patchwork-Id: 628210 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14F1CC433FE for ; Mon, 21 Nov 2022 09:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230164AbiKUJRq (ORCPT ); Mon, 21 Nov 2022 04:17:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230157AbiKUJRn (ORCPT ); Mon, 21 Nov 2022 04:17:43 -0500 Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [IPv6:2a02:6b8:0:801:2::106]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C23916585; Mon, 21 Nov 2022 01:17:39 -0800 (PST) Received: from myt5-01d0fbe499ab.qloud-c.yandex.net (myt5-01d0fbe499ab.qloud-c.yandex.net [IPv6:2a02:6b8:c12:4619:0:640:1d0:fbe4]) by forward103j.mail.yandex.net (Yandex) with ESMTP id EE18E10262F; Mon, 21 Nov 2022 12:17:37 +0300 (MSK) Received: by myt5-01d0fbe499ab.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id VC22I9egno-HaVqN7lN; Mon, 21 Nov 2022 12:17:37 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1669022257; bh=e8HT6dD/3N27O+m0P8iRhFaXnOdkCyfzpN5zPbWNkcQ=; h=Message-Id:Date:Cc:Subject:To:From; b=Jv2Tr9S0pGdAQmxuripPhHsfwOMHYwg7jVY/mAPGAdsrovkumPkKvLC8aziWtlRgq f/nK2QirBgHtVhBWOPRjdDxOzWnGP78yQlA+BeoGasvGRKX/INIRFZDv/7JXIA1b5/ MXvpTb4NuaI8e7nd2340f5vLO4Zl49pGN7op1HdE= Authentication-Results: myt5-01d0fbe499ab.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru From: Peter Kosyh To: Artur Paszkiewicz , Dan Williams , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Peter Kosyh , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] scsi: iscsi: check retval of sci_unsolicited_frame_control_get_header Date: Mon, 21 Nov 2022 12:17:32 +0300 Message-Id: <20221121091732.547363-1-pkosyh@yandex.ru> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org sci_unsolicited_frame_control_get_header may return error if frame_index is invalid. There are two calls where retval was forgotten to check. Add check of retval. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: c72086e3c289 ("isci: merge smp request substates into primary state machine") Signed-off-by: Peter Kosyh --- drivers/scsi/isci/request.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index 6370cdbfba08..e9f442d5cb73 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c @@ -1712,9 +1712,11 @@ sci_io_request_frame_handler(struct isci_request *ireq, struct ssp_frame_hdr ssp_hdr; void *frame_header; - sci_unsolicited_frame_control_get_header(&ihost->uf_control, + status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, frame_index, &frame_header); + if (status != SCI_SUCCESS) + return status; word_cnt = sizeof(struct ssp_frame_hdr) / sizeof(u32); sci_swab32_cpy(&ssp_hdr, frame_header, word_cnt); @@ -1768,9 +1770,12 @@ sci_io_request_frame_handler(struct isci_request *ireq, void *frame_header, *kaddr; u8 *rsp; - sci_unsolicited_frame_control_get_header(&ihost->uf_control, + status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, frame_index, &frame_header); + if (status != SCI_SUCCESS) + return status; + kaddr = kmap_atomic(sg_page(sg)); rsp = kaddr + sg->offset; sci_swab32_cpy(rsp, frame_header, 1);