Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1263051rwr; Thu, 20 Apr 2023 12:15:25 -0700 (PDT) X-Google-Smtp-Source: AKy350Zo9PnaUBP7hmoGgjmpvrE6AUL1Exi/aYhN7EXIJGalGCAWIxe/njcCBsqLcDRFDZ7Ww1v+ X-Received: by 2002:a05:6a00:15c9:b0:63b:854e:8459 with SMTP id o9-20020a056a0015c900b0063b854e8459mr2993128pfu.31.1682018125356; Thu, 20 Apr 2023 12:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682018125; cv=none; d=google.com; s=arc-20160816; b=LX8qEQu5lvgXCQ1vQqSIPVM6WF3f5vNVdgci1UNEYdDEDfZI1L1NbBe+qH0rOi52O2 xyDXVcWCN02QoVZgk6OCzuAhQvEgvJ1GWTIBsHnwJa5MUQbN85a/9brUekYd/iMmPlq9 smAaTiXP7P12OqXhpxGr9KCppzUJDq59X0/empldpt2KUVuhiW5iLdtZaF7irTk8d+fv 4c+d2tUSMGqf38YHcxT0anTIALenDvCu6DevthE+EkJJLvZwGbyQ6CxWe5H+BYjq+2/B qIPEJvh76tED9ZywLjAlKh4KdP/X92eCV0DEPO61R8lRpVUBOsanE9SQl3Jn5+qQa6pa a6Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:autocrypt:from :references:cc:to:subject:dkim-signature:dkim-filter; bh=ZGLYdFUKggrLnlPJtsPeuaR79mI3VFtOVyD1kwaRXxg=; b=Lqal859QstWxIifgq74MHhzR+/+6VYeZEvwjgYkA+b/ZRnWF4Lz5wKMy49Sn6B6FU6 YLOYNrA8W3iOws1NnZTdRVBlZWIpJWlPykkIGznMNl/fSJ41bPCxJiiULfbmSQt5zrEZ txsJC1MOME4yfBtG69CbdsmhX9XzY3sS39aXX2s59ojCgxZDj4rg63TzSYgijWhRD3tc eqxTV41rhYBIy9kSa0Lud9bXn0jMclVPZhmPJF8zYFx31O443Ib41jjmDDxajJS3xs1A lR0RUwhcxihH2DOPBRVJUR4CLXBdbQihzcll0GKxREuUGFddNgXZkECsVAgdg4ckG34N xqXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=VPpe38dZ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k185-20020a6384c2000000b005030a59a818si2249155pgd.402.2023.04.20.12.15.11; Thu, 20 Apr 2023 12:15:25 -0700 (PDT) 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=VPpe38dZ; 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 S231206AbjDTTDM (ORCPT + 99 others); Thu, 20 Apr 2023 15:03:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjDTTDK (ORCPT ); Thu, 20 Apr 2023 15:03:10 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB6433C22; Thu, 20 Apr 2023 12:03:03 -0700 (PDT) Received: from [10.10.2.52] (unknown [10.10.2.52]) by mail.ispras.ru (Postfix) with ESMTPSA id 7AD6644C1023; Thu, 20 Apr 2023 19:02:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 7AD6644C1023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1682017378; bh=ZGLYdFUKggrLnlPJtsPeuaR79mI3VFtOVyD1kwaRXxg=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=VPpe38dZi6DPMC6yBv3sdf22r2NOfK6M35vH9wm5WrrAMaT+MgHQhEAD0h9rpf7qH fBonYVsgR5KIrDy7Q6+QqC8MJoeK/WyDfjXvQjN4gvfhcb5JlwCbnr5dyQubsS3jsW 1v6vjCEYRYVl7+7e2dMlgzC2PL6iyOJ8fD3+SYH8= Subject: Re: [PATCH] scsi: myrs: check return value of dma_alloc_coherent() instead of using dma_mapping_error() To: Peter Kosyh , Hannes Reinecke Cc: lvc-project@linuxtesting.org, "Martin K. Petersen" , "James E.J. Bottomley" , linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org References: <20221116094147.221640-1-pkosyh@yandex.ru> From: Alexey Khoroshilov Autocrypt: addr=khoroshilov@ispras.ru; prefer-encrypt=mutual; keydata= xsFNBFtq9eIBEACxmOIPDht+aZvO9DGi4TwnZ1WTDnyDVz3Nnh0rlQCK8IssaT6wE5a95VWo iwOWalcL9bJMHQvw60JwZKFjt9oH2bov3xzx/JRCISQB4a4U1J/scWvPtabbB3t+VAodF5KZ vZ2gu/Q/Wa5JZ9aBH0IvNpBAAThFg1rBXKh7wNqrhsQlMLg+zTSK6ZctddNl6RyaJvAmbaTS sSeyUKXiabxHn3BR9jclXfmPLfWuayinBvW4J3vS+bOhbLxeu3MO0dUqeX/Nl8EAhvzo0I2d A0vRu/Ze1wU3EQYT6M8z3i1b3pdLjr/i+MI8Rgijs+TFRAhxRw/+0vHGTg6Pn02t0XkycxQR mhH3v0kVTvMyM7YSI7yXvd0QPxb1RX9AGmvbJu7eylzcq9Jla+/T3pOuWsJkbvbv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4R7AYr6DDIDxoSzR4k0ZaG uSeqh4xxQCD7vLT3JdZDyhYUJgy9mvSXdkXGdBIhVmeLch2gaWNf5UOutVJwdPbIaUDRjVoV Iw6qjKq+mnK3ttuxW5Aeg9Y1OuKEvCVu+U/iEEJxx1JRmVAYq848YqtVPY9DkZdBT4E9dHqO n8lr+XPVyMN6SBXkaR5tB6zSkSDrIw+9uv1LN7QIri43fLqhM950ltlveROEdLL1bI30lYO5 J07KmxgOjrvY8X9WOC3O0k/nFpBbbsM4zUrmF6F5wIYO99xafQOlfpUnVtbo3GnBR2LIcPYj SyY3dW28JXo2cftxIOr1edJ+fhcRqYRrPzJrQBZcE2GZjRO8tz6IOMAsc+WMtVfj5grgVHCu kK2E04Fb+Zk1eJvHYRc= Message-ID: Date: Thu, 20 Apr 2023 22:02:57 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20221116094147.221640-1-pkosyh@yandex.ru> Content-Type: text/plain; charset=utf-8 Content-Language: ru-RU Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 16.11.2022 12:41, Peter Kosyh wrote: > 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; > } > Reviewed-by: Alexey Khoroshilov Also you may want to add Fixes: 77266186397c ("scsi: myrs: Add Mylex RAID controller (SCSI interface)") -- Alexey