From patchwork Tue Oct 27 13:51:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 311821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 675C0C4363A for ; Tue, 27 Oct 2020 18:04:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A01B21556 for ; Tue, 27 Oct 2020 18:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603821868; bh=nI4jZUvTn5zfgKWaRrwFtLzGgvtf4/cDwkCh7WLCMTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2f/hx480SL+ZbhlVpQztBCTkywiko+gQjYVjyAsNJR1vX9y48YZfP3OPpwZTVeDD8 7CB6fLbZ5sdduM1kVDbrv19cVrK0CaZQwSo2bDtLi2k9EPHG0eAFPFJMFZwSrw2cOr iF4dDGHd3n6Ay+a9l0IB8ys0aFgNuuE69TWWxCGs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756555AbgJ0OSc (ORCPT ); Tue, 27 Oct 2020 10:18:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:42060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755699AbgJ0OSa (ORCPT ); Tue, 27 Oct 2020 10:18:30 -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 BB359206FA; Tue, 27 Oct 2020 14:18:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808310; bh=nI4jZUvTn5zfgKWaRrwFtLzGgvtf4/cDwkCh7WLCMTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IaaFwGxEuuv0F1tZ3dROTmDrNBOV8JIj6TZHcPR9K9IhBvKib3lRpvpIXg7xaQBh0 HEtddJ2THLrcCIn7yhiqmONLsrYiW8aGEcRida2/M2pk5k7auKWs/prj6awc/eePQa OmDsf/dN58T6HOb4TP/Tr63VOOQfYjFI73zidOTA= 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 4.19 042/264] crypto: picoxcell - Fix potential race condition bug Date: Tue, 27 Oct 2020 14:51:40 +0100 Message-Id: <20201027135432.646966687@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135430.632029009@linuxfoundation.org> References: <20201027135430.632029009@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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 e2491754c468f..1ef47f7208b92 100644 --- a/drivers/crypto/picoxcell_crypto.c +++ b/drivers/crypto/picoxcell_crypto.c @@ -1701,11 +1701,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 @@ -1713,6 +1708,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