From patchwork Fri Nov 25 21:04:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 26138 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4290888wrr; Fri, 25 Nov 2022 13:09:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf5gF6ZtdLTBwmkIDp6C5CYVYYaoBuFrkGHohIheUbUQJ2qkX30xQiaXpbA04V4pLI1xiysb X-Received: by 2002:a17:90a:bb16:b0:200:2d7f:18c2 with SMTP id u22-20020a17090abb1600b002002d7f18c2mr42437222pjr.106.1669410559541; Fri, 25 Nov 2022 13:09:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669410559; cv=none; d=google.com; s=arc-20160816; b=XCpX/8LkxlR7b2aQjPxgMEIe9cHrGYBoRCUbw4F9E7L3OShIzmffiAq59Y0dLt5qMc uHbDyWHIwVywzsTFw9hT3c8BNEjTetgo2P5ou8H7P0zMp7683e+Sc2aYOqwiwnRkyLAb vKPufc0vnF3D2i2nnDPN4rab/zRpMeGDZP5Y95bTGa69fwXFL3kqZWFyQUxXAFMhfi+V s+8MumwdP7OqsuMQGcoNO+UstKpxWSWQdcWxarDfzupzrVJC+AvDXkMNH8A0erixrUOI G/Ofd6JFpeEOiz8Ytcny2bEIfXibAWsvL7+JI/ihBFvEahSIVkjxeXAudUGNCzS0kw0A sn3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=gv0SXRdsM8PzdgCeoPT9rv4Jtt/qWR7XgDFUEPFsVV8=; b=f7EbRhHxLj3aUMXeXtzJuhaRjNs5TawxQc5QraVFHhokoWqjy3zxQ5P5nW9JrTaLcN XZzpGQpXMYcY2eXc9YKFdWeS7bCJHEDd0Xhegrm1PS3xJNJDC9dKYrGm0SLWnGAC6XAm G0erixKMkj/j+iemzFVqvWz7FcgI21xweXcgOVhvGRjamhjfp0667QEImjBNmt8ud8Kd TpT+0dDz/JXtJRJMqinD260nXIuh0uy1PBk2S/U4zlb13VMS8Shz2Xl3zOrgOGpfDCKA izSSCQPaGA0cuUVDZq4FGJK3lE3TuPbHgihIzn0v+lYzIxCdrbmcpCqtI7hCbssYcGNR I2Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=o20EMoup; 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=ispras.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s21-20020a656915000000b004772bd1b7b6si5632660pgq.43.2022.11.25.13.09.04; Fri, 25 Nov 2022 13:09:19 -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=@ispras.ru header.s=default header.b=o20EMoup; 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=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229987AbiKYVFc (ORCPT + 99 others); Fri, 25 Nov 2022 16:05:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229495AbiKYVFb (ORCPT ); Fri, 25 Nov 2022 16:05:31 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19630442C5; Fri, 25 Nov 2022 13:05:30 -0800 (PST) Received: from hednb3.intra.ispras.ru (unknown [10.10.2.52]) by mail.ispras.ru (Postfix) with ESMTPSA id B7E39419E9E1; Fri, 25 Nov 2022 21:05:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru B7E39419E9E1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1669410325; bh=gv0SXRdsM8PzdgCeoPT9rv4Jtt/qWR7XgDFUEPFsVV8=; h=From:To:Cc:Subject:Date:From; b=o20EMoupgJpijvO6b6lw/bNuICKYfkb3olBc7A1d8BKLSH5aVCwYeYo3xHxSalorG nTanv9X7HWhNaq+oTEhkNtETtVoV1oFJgFLkOBTd5Xtk1eeF/yjQXZawvtN/jNN/8b tb0e88srbHB65ohvkuVzpien8Y56wDhiUpw+gvnU= From: Alexey Khoroshilov To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: Alexey Khoroshilov , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, Semyon Verchenko Subject: [PATCH] scsi: initio: Add checks for errors in initio_msgin() Date: Sat, 26 Nov 2022 00:04:04 +0300 Message-Id: <1669410244-5565-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 2.7.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750503847012867940?= X-GMAIL-MSGID: =?utf-8?q?1750503847012867940?= The initio_msgin() calls initio_msgin_accept(), initio_msgin_reject() and initio_msgin_extend(), but does not check if they are succeed. It is not consistent with the other code of the driver. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 72d39fea9017 ("[SCSI] initio: Convert into a real Linux driver and update to modern style") Signed-off-by: Semyon Verchenko Signed-off-by: Alexey Khoroshilov --- drivers/scsi/initio.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c index 375261d67619..ee451aa34143 100644 --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c @@ -2065,7 +2065,8 @@ static int initio_msgin(struct initio_host * host) case SAVE_POINTERS: case RESTORE_POINTERS: case NOP: - initio_msgin_accept(host); + if (initio_msgin_accept(host) == -1) + return -1; break; case MESSAGE_REJECT: /* Clear ATN first */ outb((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)), @@ -2074,20 +2075,24 @@ static int initio_msgin(struct initio_host * host) if ((active_tc->flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0) /* do sync nego */ outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN), host->addr + TUL_SSignal); - initio_msgin_accept(host); + if (initio_msgin_accept(host) == -1) + return -1; break; case EXTENDED_MESSAGE: /* extended msg */ - initio_msgin_extend(host); + if (initio_msgin_extend(host) == -1) + return -1; break; case IGNORE_WIDE_RESIDUE: - initio_msgin_accept(host); + if (initio_msgin_accept(host) == -1) + return -1; break; case COMMAND_COMPLETE: outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0); outb(TSC_MSG_ACCEPT, host->addr + TUL_SCmd); return initio_wait_done_disc(host); default: - initio_msgout_reject(host); + if (initio_msgout_reject(host) == -1) + return -1; break; } if (host->phase != MSG_IN)