Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp735440lqe; Sun, 7 Apr 2024 01:06:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVKoxjcoQ2K8n1R+GLnsppcFwz4/lWSKut8/4/EsFIbJ2W4zuZY9wycKxiEhdksYVO7RXVO1/P2JqkyVbmqo+attJuiD1erFdUX44UDrQ== X-Google-Smtp-Source: AGHT+IGd966VcnagrFQvyI249rlknmaieu4hzJiegIwdPaRyNYFe/NOX0wPaW8OG1JUJ4fnisDgl X-Received: by 2002:ac8:5e06:0:b0:434:72eb:99d5 with SMTP id h6-20020ac85e06000000b0043472eb99d5mr4258417qtx.3.1712477197969; Sun, 07 Apr 2024 01:06:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712477197; cv=pass; d=google.com; s=arc-20160816; b=cOKsRcHR5Jvv/RPCkFCc0DtH7z+1zIDzbACYPnShk+YAvS5pTZLRLdogsVVpGZnDdj 2gHASNxvY6Jt47lg6lTdS/v8DrgAOhbPGCqt6NfO3VHxe1skNHrei4czN5jnAWUnOto5 lIwq6axC/C5xQ2pVEez13sNPoJlfMj5/rJYJhdkU8ohxEBtOwaM+zrdt97Sy5HyUafw4 KmO0HLS8Ef/BCtyyaK4GZD9o1ugnxvXPOcvWyz67u3eiHXhbiv9uU2DQ14nJOVQq88V+ XQ5gNL/tJenrDfhQBFpgwOidQtg843RrqV13EnqS12r9RFlFXxnlan2eFF5dap5PYHe/ 0Xpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=jukBRKhL+48W04Uka3GEXlVaop1nMaT7+Kvn3K0ymBA=; fh=VzMToBYo5MUfLaQO74C2Chjt/otG4r80qnd7ynZ/RBQ=; b=XaPjz+kC0OEZNHRNOJgjdOACC/IQLswTfKCi8iRAq8lS1kglM0L0JyrmU6Pz7SV6LQ 4dsNrv51AnI5XIEAGe7a+J9dq7YvaOSDEzweKQMRCsZcxol9s1eRy3pcXB3aoFIZ1jqJ yCv7XG4N3bIkmW8VeJmnzKO2XcjUFyWi507GChY3yFYt5PjQsCVf7Ikv9hwtNggHix0t mwGxomz6ckoFd2d/hq9cZt+OM/ku+qZ8Zaaxu6h8Owtk92f3/xiMIjJ5R68LbQFfiudA WW/SFPTlSETUmXi4rc+mtcqx82hv7DLYH/Opkjt11I+/x1TsEXDG6oJFkXTsK1dKufcj fIkQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-crypto+bounces-3389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3389-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u2-20020a05622a198200b00432cf1c9dcfsi163897qtc.632.2024.04.07.01.06.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 01:06:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-crypto+bounces-3389-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3389-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id AF6511C21321 for ; Sun, 7 Apr 2024 08:06:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 65D802C19B; Sun, 7 Apr 2024 08:04:40 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69D8B25776; Sun, 7 Apr 2024 08:04:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712477080; cv=none; b=AwJbpMwSnbDbP5f0pNopOqARZ5trRr+9TYQc5hxGNG9cdPimxvaxBZ9RPuNgyFS6LsZ3/Y+237iFyHe/Ou5P8xmtRIDoUt4cfbZWbjTCl0LbztJTh2UrlLMNjWNfnyHUm91aP5EHDxJAeccCk5KZQzrmn42eFrNudsMv2YlzvRQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712477080; c=relaxed/simple; bh=59QhSJcBaUPchWNL7bHjebEqRTh9j7wS95eCWvo0nRg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e8j5U/CKLIXOZDb88wFag3p9KQjy/QlyzT3fTGlbMtwu7LOA/lk87gT55DtKxMj7ZBugMZ/lPJB9sLzCysljgChjZsI7CweFZidmhoCYSVVdPWCeI1wVXUKr+GQXL9+abyKctEaeDYYi56pRKmNW8sce2cNSXWSmcThh+9o1XHU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4VC4VK0RZLz1wqPL; Sun, 7 Apr 2024 16:03:37 +0800 (CST) Received: from kwepemi500025.china.huawei.com (unknown [7.221.188.170]) by mail.maildlp.com (Postfix) with ESMTPS id 1A7D51A0172; Sun, 7 Apr 2024 16:04:31 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500025.china.huawei.com (7.221.188.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Sun, 7 Apr 2024 16:04:30 +0800 From: Chenghai Huang To: , CC: , , , , , , , , , , , Subject: [PATCH v2 4/9] crypto: hisilicon/debugfs - Fix the processing logic issue in the debugfs creation Date: Sun, 7 Apr 2024 15:59:55 +0800 Message-ID: <20240407080000.673435-5-huangchenghai2@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240407080000.673435-1-huangchenghai2@huawei.com> References: <20240407080000.673435-1-huangchenghai2@huawei.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500025.china.huawei.com (7.221.188.170) There is a scenario where the file directory is created but the file attribute is not set. In this case, if a user accesses the file, an error occurs. So adjust the processing logic in the debugfs creation to prevent the file from being accessed before the file attributes such as the index are set. Signed-off-by: Chenghai Huang --- drivers/crypto/hisilicon/debugfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/hisilicon/debugfs.c b/drivers/crypto/hisilicon/debugfs.c index 6351a452878d..e9fa42381242 100644 --- a/drivers/crypto/hisilicon/debugfs.c +++ b/drivers/crypto/hisilicon/debugfs.c @@ -1090,12 +1090,12 @@ static void qm_create_debugfs_file(struct hisi_qm *qm, struct dentry *dir, { struct debugfs_file *file = qm->debug.files + index; - debugfs_create_file(qm_debug_file_name[index], 0600, dir, file, - &qm_debug_fops); - file->index = index; mutex_init(&file->lock); file->debug = &qm->debug; + + debugfs_create_file(qm_debug_file_name[index], 0600, dir, file, + &qm_debug_fops); } static int qm_debugfs_atomic64_set(void *data, u64 val) -- 2.30.0