Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2600856lqz; Wed, 3 Apr 2024 03:06:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXVogfhYfa7cpNuARurIu/Mp3NEZxn00lwcSNkw3MTIujVPP65o/DapwbkLePsQPGrcaaYOYRor505dExpk3f1pmpqeG7JBpve3eCDJhQ== X-Google-Smtp-Source: AGHT+IF8LsG0/EcRpB3GoJTLNd6Rh6d11a49OaOI5OW9aGP20w+K0ukWzp3c59Qhusi+a4TI7YEB X-Received: by 2002:a17:906:470c:b0:a4e:6957:de24 with SMTP id y12-20020a170906470c00b00a4e6957de24mr1492083ejq.37.1712138776329; Wed, 03 Apr 2024 03:06:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712138776; cv=pass; d=google.com; s=arc-20160816; b=PCY5QliAkX3uUII7ea4Y99r+VtADfzyEFxUYpPQMNxvdP2fErtL78Ah5IJcOyL9P32 O8ByLngjh63UEYVwHzPMLYnBHSqx20YZPGUMXSwwR3MU+RqMcFVeZ4sHNgrT8w+iRnne 6+6UaT4ESIbdDabwwPD6ZB2SKOaIZ2yBhRcQ7sK3LON+YxEIjUK/1poIZJUH0r26ztXc 4xCOSpqgVMZdt/f+TTrmyw26z4LZUDExXW9SYTxcI/OE11M0OKljwvPo0BFGlFL6H1PV TA1FWGFf+gWiI5Q2SIO0bClnBOSbLgv7JC8tqi2PIwDZEoE2IzweyN+5h9cfpIB9GTe8 ytTQ== 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=vmsETypIgb9M0P3n28hGJl7wr1ED460R04f3/RKoop8uaA3guHen6+PyizwpPDFooZ lrcZ4aD6rOmvDB7+CeCEBfdgTLsoVq5n3VAINdSr50AIF0138FN73XS8hBbnXJH5DqiJ HwgG3fUU62FATfuQveAgVXJzNjTZUPVCeI6A5lLMK8Q5n04mfavlbvkkpLDsQMqjuT/M N3MnR7rre4cjMUBQxgRcMe0Tq6PFuz6hNjda7HTje5Y0aD+6D1jWxnxmI9HQwManhGBK yF3g86TtSzyxOomm/R+K7OazBpSWGvVqFTSA2N61m0PwUTAGbbVk+iyXk54gHR/B6ftu 8xtA==; 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-3289-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3289-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f10-20020a17090631ca00b00a46e6d3a27esi6383979ejf.527.2024.04.03.03.06.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 03:06:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3289-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-3289-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3289-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0F4721F2AE12 for ; Wed, 3 Apr 2024 10:06:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07EDE136671; Wed, 3 Apr 2024 10:05:32 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (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 EE081135A44; Wed, 3 Apr 2024 10:05:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712138731; cv=none; b=aSn5w3t19kTxvxmqpL5Y6gokG+MA5fCpZjvpftuQ4+bRUxHX6F3C17HPwGoUzEOpVRQfJyyGNOt8x/95c390+qpvJFBZlPG20TWI7aCv0/Ac0voaoOpaMKJyc2vDlgbHGgnPrOnfV8s4WIrEQCiEDtBMqRoWUl0TwK3Es/VnpVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712138731; c=relaxed/simple; bh=59QhSJcBaUPchWNL7bHjebEqRTh9j7wS95eCWvo0nRg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YEz3YYTaRaPO0X2PmA6RMHsFXyS8drUO0oGxWcxGcCjjBXw/APyl/COSphoTGJD6Y/L94POq2B4vm9QEeCsnK7byYNpVZAdSkXXhZzNZxdrNKI0+TrBXZILLBBl5JkGnuosWN+sJZc27ghbAMgW6BxFgmu01q6WucMRApPPHJQ0= 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.255 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.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4V8gKn6y5Nz1QCDj; Wed, 3 Apr 2024 18:02:53 +0800 (CST) Received: from dggpemd200003.china.huawei.com (unknown [7.185.36.122]) by mail.maildlp.com (Postfix) with ESMTPS id 20CB818005D; Wed, 3 Apr 2024 18:05:28 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by dggpemd200003.china.huawei.com (7.185.36.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Wed, 3 Apr 2024 18:05:27 +0800 From: Chenghai Huang To: , CC: , , , , , , , , , , , Subject: [PATCH 4/9] crypto: hisilicon/debugfs - Fix the processing logic issue in the debugfs creation Date: Wed, 3 Apr 2024 18:00:57 +0800 Message-ID: <20240403100102.2735306-5-huangchenghai2@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240403100102.2735306-1-huangchenghai2@huawei.com> References: <20240403100102.2735306-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 dggpemd200003.china.huawei.com (7.185.36.122) 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