Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4010688rwb; Mon, 21 Nov 2022 02:35:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Rs3IUVBQacVtnw8kNcM9CdL4cqfnmJ451JyMw4WE/FSpFav6nxih9FZeKj3q4+rXOc0L/ X-Received: by 2002:a17:903:2144:b0:186:e5dc:4c55 with SMTP id s4-20020a170903214400b00186e5dc4c55mr2567750ple.148.1669026939238; Mon, 21 Nov 2022 02:35:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669026939; cv=none; d=google.com; s=arc-20160816; b=wswIFnBsnbR5MXijjUeoF1VttJOOZvrtL8OMtOlQ3kgHaUmAH1StMZltfR9r+VmAuL YgnRMFyLlZjKAsZvMA2V/BK5yrS8tSDYwxYSN2pUscfUO10LsrvG5ZpWkgh3mj5WY+Hi 0jVLsSmd6KiYEhPcDXodKP21F+Q3WKW9WBmjf4VOMOfDcXJtk6cM5RE7BVZebTrHw3Ni A6W2Aej8jzSulDzMt8kIioVSz2InXeguT+ZtdFlZ3tGZp/qTSDl4/SS8NDaqsoKQuxgs Bkh1xjUEl1EvG9FHNkzGpwJozyzwPNTVnmT42gG6g1qkPx3X40VxaKJDD5VO967KbfhU r8fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=e8HT6dD/3N27O+m0P8iRhFaXnOdkCyfzpN5zPbWNkcQ=; b=ARl/XPGUy1aaGwzLLI5gHQCCQJQ3ddsYu8lwPJ2JBsf2YewBr/2uil1S82eE9Qr+Sz mYwZqkAJIXztK6Y36WQ9F00b7JNTgMRxzPgCCetrv4nWDtLoQPjFdjaTP9vopDnS9wTw Vn1ngoZ+VSqVx0JxMpQjl25PJJVZULUVkl/mNEx72pyTgEQ5pKRU28Nd9cNK1NFr2Nt8 nN2wv8osNWT1JEodSVD8cNFWrLsIA7R49XFt2Wu4jOPJtPsMouYfXTPV/73qwsH20Nmd XP5YtapuTmxU0Y0gy4fasc24FcvvK2eCLTPE2VnXhnUeOJk4xQ3zP53CG8/4yuuzpweL OAoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=Jv2Tr9S0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a056a00190a00b00557e99763d3si11423272pfi.93.2022.11.21.02.35.27; Mon, 21 Nov 2022 02:35:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=Jv2Tr9S0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230177AbiKUJRr (ORCPT + 91 others); Mon, 21 Nov 2022 04:17:47 -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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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); -- 2.38.1