Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp345258rwb; Wed, 28 Sep 2022 03:37:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM45czXlyUM3oVJt6/VtEzEfQBlYV158v8RAJjOEa7zltsiShOFExYUzD58QIilZI0W0fEbz X-Received: by 2002:a05:6402:524a:b0:450:bab6:cd5f with SMTP id t10-20020a056402524a00b00450bab6cd5fmr32257584edd.233.1664361457897; Wed, 28 Sep 2022 03:37:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664361457; cv=none; d=google.com; s=arc-20160816; b=U5IJvCi2hOYVaa0D0BnTfd2nLsKtg1kZmR7VqwrRb9xeWgDmpDLlHydwJFcrKv6B7e IJR0yLZ19E97L7MuNGnUTXBI02Ar6TleC+eARAdbDcL0nNR+ke6uFZEXXzlqFN7sr3mY 5TH7+eHFGposeZ6nqd0nHWHxzrQYIO1rDrfVy0NvpHUc7qdC/KI3PHO+ePmDo519EJRY JC3iixUVp/FSSawQquGHydXflav+sryIhaafjWOZDT8Y/ar1ZE6Lp8UBs/QcHQBAFj9q f+PW0SdiOxdu3Dv/5XxORGIgF7OODiAeQOzxCVLRduauabuHtHB65RxQmrC39sOy3H42 C7XA== 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; bh=s6TuWqTTizy28HSOYLpFKanskTjCqySuNh5hE7IDfLw=; b=nJw9EQkK7ycjVv+VeeyuRVZqNCCkMQAMCB5nYv31tNbo/Y8xB7ffVV7bZ42+EWBvUt zY7F8MAosfkZD0m+j10Jg14H+tgtgjt7ISHkoGGV9GmaDMwp7K6DLeVRFnOT/uX/RsBW qAdi+gxNCsaJxXnYiqJ1e2SoUp23K79ZZGjku6alnrx90A+FwRdpWrbyHbryRahc0aA2 DMKqwvQND68w/picdivbZKazMyK8CZBLfgpD+5Kg0+srVxSdvqtWXvjFp8oZjIwsu9pR ssvj93A9VqAnXXjXO2dBOFKBM+G/qfTDhW8KpWGQv1dX4ARSbkeSf664Gc2u+3yzDbpU rQEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m4-20020a056402430400b004551a7e54dbsi5129939edc.226.2022.09.28.03.37.03; Wed, 28 Sep 2022 03:37:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230486AbiI1K01 (ORCPT + 99 others); Wed, 28 Sep 2022 06:26:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232166AbiI1K00 (ORCPT ); Wed, 28 Sep 2022 06:26:26 -0400 X-Greylist: delayed 68 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 28 Sep 2022 03:26:23 PDT Received: from exchange.fintech.ru (e10edge.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78E1EB5A46; Wed, 28 Sep 2022 03:26:23 -0700 (PDT) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Wed, 28 Sep 2022 13:25:06 +0300 Received: from KANASHIN1.fintech.ru (10.0.253.125) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 28 Sep 2022 13:25:06 +0300 From: Natalia Petrova To: Herbert Xu , "David S. Miller" CC: Natalia Petrova , , , , "Alexey Khoroshilov" Subject: [PATCH] nitrox: avoid double free on error path in nitrox_sriov_init() Date: Wed, 28 Sep 2022 13:25:05 +0300 Message-ID: <20220928102505.39709-1-n.petrova@fintech.ru> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.253.125] X-ClientProxiedBy: Ex16-01.fintech.ru (10.0.10.18) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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-crypto@vger.kernel.org If alloc_workqueue() fails in nitrox_mbox_init() it deallocates ndev->iov.vfdev and returns error code, but then nitrox_sriov_init() calls nitrox_sriov_cleanup() where ndev->iov.vfdev is deallocated again. Fix this by nulling ndev->iov.vfdev after the first deallocation. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Natalia Petrova Signed-off-by: Alexey Khoroshilov --- drivers/crypto/cavium/nitrox/nitrox_mbx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/cavium/nitrox/nitrox_mbx.c b/drivers/crypto/cavium/nitrox/nitrox_mbx.c index 9e7308e39b30..d4e06999af9b 100644 --- a/drivers/crypto/cavium/nitrox/nitrox_mbx.c +++ b/drivers/crypto/cavium/nitrox/nitrox_mbx.c @@ -195,6 +195,7 @@ int nitrox_mbox_init(struct nitrox_device *ndev) ndev->iov.pf2vf_wq = alloc_workqueue("nitrox_pf2vf", 0, 0); if (!ndev->iov.pf2vf_wq) { kfree(ndev->iov.vfdev); + ndev->iov.vfdev = NULL; return -ENOMEM; } /* enable pf2vf mailbox interrupts */ -- 2.34.1