Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1216785pxx; Tue, 27 Oct 2020 10:57:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9YqLf86Puwx/FVjxPCswfGKVGbp6vDAOdr3rwwqyOSTPr21YaixIA+kCU+yASuobqgZs7 X-Received: by 2002:a50:f307:: with SMTP id p7mr3431767edm.235.1603821472360; Tue, 27 Oct 2020 10:57:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603821472; cv=none; d=google.com; s=arc-20160816; b=Ex1pXB8MbKW27YrZ0+wCDzAfwRs27cdqH/PWqTyi6zVHO0Y3Z/aavGWZcg/JMU5mo4 oowWfhu2fNALS76Z7Vg9NA5R9qEt2W81jwUtmJPUPw9wD46LHwdVVRkI782BeipNJo29 v4Xe+9XgYAWY8hi4Jt1LFdZIRSa+teOvxuhMw+5Zkj6BuvN42Sf6nwTkVf97nbrhqZZ2 SR1QFFRPnQROzZbA2DZ/N6kjBPUXuG2ndgRDTMbUMWRDrOYKhyREt6arC73SS+GzUON6 r7co7oLFORtUEwDqSkgYYwUJeNA44t6/CxVvXcVObfVEO4DgBFIWt0uvyK1ASuA1Q1vp iuWA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=R7dMDU9MKdciBf9JP1WT1um739NNg3HKpfW7Mc5de4c=; b=qvIJBWpYrP1E4l0WluhdYMmXhnv8AVbav3YoqAIVTQegT6NyXIMSiqEDzfBM/AwZOK D9ZoGbqXCsw1N2uywKdRTd9Q02hKYwfo2r5ru3AvLfHp5JJY/6A+QsK12/k57csnOI/Y iaiPxfG49VLS2omUZHC69weEekoFXCVhbgVDO/zqr6XjyI0vqa651AFtSZPhjLNe5Df9 2q42ihqjw+pLdqZMdHdmrXEq+4/WMUTHyeJWk58Nk/l9E50PPoOfTo9bb9LzMyu20kLN lh5vt+FYbHEMov4ytMGyEMunr6eel6nUorIKQ08g95mzbBAGM2vkkXaXUW8bAjMeo/cS Oa7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JFiKE2Mp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d17si1424510edz.488.2020.10.27.10.57.29; Tue, 27 Oct 2020 10:57:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JFiKE2Mp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1819002AbgJ0R0b (ORCPT + 99 others); Tue, 27 Oct 2020 13:26:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:52254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751686AbgJ0Owf (ORCPT ); Tue, 27 Oct 2020 10:52:35 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E8BD220679; Tue, 27 Oct 2020 14:52:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810344; bh=oFzguebNLEhFeDGfuSs9IKduhhslEnjrkch0fj8EnKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JFiKE2MpETFlGJMnW7sGOP3mF23Uw3tg8GkWYkQW9rldJnwh8egjFIE7eagKoMeKQ B4RMU2ye7ElJzbM0FLZEGRZnCMJqOigXlPBFHiE5GP7m545BMTqYUwbZ7gLoqmBNmA 3sosVTq2m9JOYrlLEUliqDdZoE7TkLDSXav7jD3c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Madhuparna Bhowmik , Jamie Iles , Herbert Xu , Sasha Levin Subject: [PATCH 5.8 105/633] crypto: picoxcell - Fix potential race condition bug Date: Tue, 27 Oct 2020 14:47:28 +0100 Message-Id: <20201027135527.606837533@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Madhuparna Bhowmik [ Upstream commit 64f4a62e3b17f1e473f971127c2924cae42afc82 ] engine->stat_irq_thresh was initialized after device_create_file() in the probe function, the initialization may race with call to spacc_stat_irq_thresh_store() which updates engine->stat_irq_thresh, therefore initialize it before creating the file in probe function. Found by Linux Driver Verification project (linuxtesting.org). Fixes: ce92136843cb ("crypto: picoxcell - add support for the...") Signed-off-by: Madhuparna Bhowmik Acked-by: Jamie Iles Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/picoxcell_crypto.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/picoxcell_crypto.c b/drivers/crypto/picoxcell_crypto.c index 7384e91c8b32b..0d32b641a7f9d 100644 --- a/drivers/crypto/picoxcell_crypto.c +++ b/drivers/crypto/picoxcell_crypto.c @@ -1666,11 +1666,6 @@ static int spacc_probe(struct platform_device *pdev) goto err_clk_put; } - ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh); - if (ret) - goto err_clk_disable; - - /* * Use an IRQ threshold of 50% as a default. This seems to be a * reasonable trade off of latency against throughput but can be @@ -1678,6 +1673,10 @@ static int spacc_probe(struct platform_device *pdev) */ engine->stat_irq_thresh = (engine->fifo_sz / 2); + ret = device_create_file(&pdev->dev, &dev_attr_stat_irq_thresh); + if (ret) + goto err_clk_disable; + /* * Configure the interrupts. We only use the STAT_CNT interrupt as we * only submit a new packet for processing when we complete another in -- 2.25.1