Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp383500rwb; Wed, 16 Nov 2022 01:58:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf7b0m0uvauQv3x+ycKtGTVSbPV+WF2aSvaQBdEp4FOHsOgdoLGK9+KcagIgvsn3Lov3X6cL X-Received: by 2002:a17:906:1805:b0:78d:36d7:ed29 with SMTP id v5-20020a170906180500b0078d36d7ed29mr17631557eje.655.1668592709174; Wed, 16 Nov 2022 01:58:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668592709; cv=none; d=google.com; s=arc-20160816; b=fK5czwLB07lEGU29BvdDbBoNkRbsoIRzNagcbcnDzlluDiAXfxOs+9OepWvpvf/dqU ewFHIJnwvmJMwIWXLPYoWFXdtCM3A3c/XyqXOuJtlznFkBoD2Lj2rhwHO11GMwYEjOzo HzFuf0b/XAFv8KP4jj5qIqv0jT4ngpQIR9TjqBdk3DKRTm8UEKglkTACpet41zGzhvWT OVeL4Y3iyfWKBoHO1WCs0z/wvqA0JG2HFbLUOKARWFXHQIV//pJ/qJgIGFq6TTU5juhn greTBk9luc55Htz/qFCUzeZXe4n/BjUgXxq9HubJPuiJ2hDV2ux4zLHqumAKdIg4cCa9 dUoQ== 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=NxC0GTnHZ1GOnkVDWk1bYH/JQTZsJK3+UhL5Lol/IJ4=; b=qGd4IR+7NWfznj/76JVW2ByHL7iOkU7kVT45VAKiKRyZ+SiqJ3A8LT4ccs70gkU7Rq puaXixY0WkgtrjL7xSSLycHLme9oqRMlEr5C/ctmZSr9Z96bbVseG0BVym8Q46edyEeZ 9XUZZ2meKOoBE0rshE+byeNA8AEkLx9VKhOcy+jAVNQxAbbt/oWoHhZsrqJwirZ2MiTr 9j/MY5BH2nlCdKipabfm6d8XhSEZ70TcawIrtJeDL+pHlYvQOUol+ZNJVJme6iI2EJ29 H2+JGMJKnWNN3gCU/IXbXYGU4HJndxVFQ7uc1V2TPFjCIJOOb1ugXc2O5wmo4+8wj4Nx 2QTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=m8kbW1Uo; 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 dz19-20020a0564021d5300b00458ab54baa5si13916640edb.503.2022.11.16.01.58.04; Wed, 16 Nov 2022 01:58:29 -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=m8kbW1Uo; 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 S232599AbiKPJul (ORCPT + 91 others); Wed, 16 Nov 2022 04:50:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiKPJuj (ORCPT ); Wed, 16 Nov 2022 04:50:39 -0500 X-Greylist: delayed 382 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 16 Nov 2022 01:50:37 PST Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0109E266B; Wed, 16 Nov 2022 01:50:37 -0800 (PST) Received: from sas2-e7f6fb703652.qloud-c.yandex.net (sas2-e7f6fb703652.qloud-c.yandex.net [IPv6:2a02:6b8:c14:4fa6:0:640:e7f6:fb70]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 6304D2FC33E0; Wed, 16 Nov 2022 12:41:52 +0300 (MSK) Received: by sas2-e7f6fb703652.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id 3Hc0AlxaOn-fpVKvwam; Wed, 16 Nov 2022 12:41:51 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1668591711; bh=NxC0GTnHZ1GOnkVDWk1bYH/JQTZsJK3+UhL5Lol/IJ4=; h=Message-Id:Date:Cc:Subject:To:From; b=m8kbW1UotzyT81MDCGb5fPDRmKTigL06CtgPp5k5k80ZQBJ+w26nET4PZ42vdOw5G LlU10SuRHU9maAcN5WVIqL7zb+Dqfc7Z/ttBgc0+UmdBFiFyvi9qfrFHZbuQZMm+kf nmS+ltiy9ws7LrVDJC3X3JEfdtS8G0DDgXlaITV4= Authentication-Results: sas2-e7f6fb703652.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru From: Peter Kosyh To: Hannes Reinecke Cc: Peter Kosyh , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] scsi: myrs: check return value of dma_alloc_coherent() instead of using dma_mapping_error() Date: Wed, 16 Nov 2022 12:41:47 +0300 Message-Id: <20221116094147.221640-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,RCVD_IN_MSPIKE_H2, 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 dma_alloc_coherent() may leave third parameter uninitialized. So it is not safe to use dma_mapping_error() without checking return value of dma_alloc_coherent(). Check the return value of dma_alloc_coherent() to detect an error. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Peter Kosyh --- drivers/scsi/myrs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c index 7eb8c39da366..1811c1a6385b 100644 --- a/drivers/scsi/myrs.c +++ b/drivers/scsi/myrs.c @@ -498,14 +498,14 @@ static bool myrs_enable_mmio_mbox(struct myrs_hba *cs, /* Temporary dma mapping, used only in the scope of this function */ mbox = dma_alloc_coherent(&pdev->dev, sizeof(union myrs_cmd_mbox), &mbox_addr, GFP_KERNEL); - if (dma_mapping_error(&pdev->dev, mbox_addr)) + if (!mbox) return false; /* These are the base addresses for the command memory mailbox array */ cs->cmd_mbox_size = MYRS_MAX_CMD_MBOX * sizeof(union myrs_cmd_mbox); cmd_mbox = dma_alloc_coherent(&pdev->dev, cs->cmd_mbox_size, &cs->cmd_mbox_addr, GFP_KERNEL); - if (dma_mapping_error(&pdev->dev, cs->cmd_mbox_addr)) { + if (!cmd_mbox) { dev_err(&pdev->dev, "Failed to map command mailbox\n"); goto out_free; } -- 2.38.1