Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1384710rdb; Wed, 20 Sep 2023 07:48:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IET7++b10RI1U/UD71L8vl1YUcCXSrAYMXgnIOI+dz27yFxdi5KSn2Txdwn6nnZfbaN01wq X-Received: by 2002:a05:6358:284:b0:143:61d:ffd3 with SMTP id w4-20020a056358028400b00143061dffd3mr3037751rwj.4.1695221294907; Wed, 20 Sep 2023 07:48:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695221294; cv=none; d=google.com; s=arc-20160816; b=N21QmJgLCPxzKxil1tKBi19aLVA2pLeYD3OFRSUf1E7I7ZxIyW0/ondrB5aW2DpmK7 HtHk1eTX/x3Y8U2dftO/KNIr/FEQ9uhfKXslTWJtuQvu3+67APPvP0TN9JlEvbLkVCq+ ClLkJ3usEKmYDNgO2SNP3BrqvXJ8CPbbdQHCmxs9y07xCdHge3PIHwHk25cW5CIQtclw CuLkj/aPMENZbfi2eR2GVDPRKcYu0+275c2or+0F0qOdRW+LXOH15Zyf9rWG+2kioxCv d8DQvjk3iMDc0ip3LNsXtowuzRz30SxltVefNF3ho8b8ib5G/kpsReKFYqH+6dgY/2Mx XtlQ== 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:dkim-signature; bh=9RDULjoQzHjU0PTxlc2WdDnc+PjIGpAs5L7B9DlE1S8=; fh=5h34hxNlo6PLyhnfJ22ZR1reAhuPMfSys28GnByjiBA=; b=qJTmdpH3jkveRV3mBcNSy9Qb2TqYqd3yTDu4V3Mmmt59j18+kaNDTE2N321Si/QhL6 dm5U95BVlruuM6DPoAHWrtfjT0ZEmKfjJNfW/dbMw0R5f6fPRhmf4MjjclEmkGM3BcK6 cFF/bVccNxulOlMIgEWO+rk/dauR7X/YkuTiRw2u75M/M38hGRNaJejQ91LHway95GB9 LdF5GbFb/1MhjaPKc4FaZdiQingAQtsKuCLT7knAh4YOTfXI8K0z2004qc9F7A6nqa3a O7bpJ9v/Cp2SxGxi3Qr8FFBiQkMRxGvLMFPq7v943dKinxknkz5QVCTCwqJjTI1j8eym 9WuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=joVd7PI6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id az1-20020a056a02004100b00565e0624182si11966306pgb.404.2023.09.20.07.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 07:48:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=joVd7PI6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9EA0A802572A; Wed, 20 Sep 2023 02:12:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233907AbjITJMu (ORCPT + 99 others); Wed, 20 Sep 2023 05:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233766AbjITJMo (ORCPT ); Wed, 20 Sep 2023 05:12:44 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5057683; Wed, 20 Sep 2023 02:12:37 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1bf7a6509deso49511045ad.3; Wed, 20 Sep 2023 02:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695201157; x=1695805957; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9RDULjoQzHjU0PTxlc2WdDnc+PjIGpAs5L7B9DlE1S8=; b=joVd7PI6EwxWeGhUZuaj58hCTKw6OecX+5EkDdFVRDHqAadvu9uafwaDgEa6VD/E91 5Nf/bBRSGRIYiq7ADaO93Enfx0xCNDzZEnolc2kXIP0zJ4dLa/LTCnJaOLVz9qtTlJ/y L+CaerHZqUGxlPWdSd9Hn+yRtpPs+VlhGT/F1VH0NN5iAWwg/wvQxOmsOMciFWxrlLlJ 30eDEqTf2bqnFEk/SPMg40YPxoTnjkgF6i7yESSPG4N8Lf+J2GCD8m/3Ejb7w3C+TSOj SH43Q6ozfjh4YVvDLjMhTdo26/TzhAYdcYLWnYrRGtjGLbEr2JEJ8bVnNIfld6zx8XYh y9QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695201157; x=1695805957; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9RDULjoQzHjU0PTxlc2WdDnc+PjIGpAs5L7B9DlE1S8=; b=MQ5XfMsj7hXjfYpBomKukGr1pLCB5NTRJYJDynpmnSDhsZnpaoYNtw1xMUDu7o+Y6N a0UZmaoLVcNaIdpwLShC/sUf3oYw1rzcmDYDlsyZgHM72KaoVVXyFWZd+/4x5Si138jh JVnLoJybbBm6aKeXHl1pKUEHY8KV7dZzFZNPfrMrZb6IkaAkEGOhtA0juBHyaOkr2D0q qKE24S1i9bjEW7IO1tRnpbCsPICzSVk+DH+KuD331sSuJR5nsXDZ81ENVJeBH65eMBnd XctboCQB5IRQGH4QY5HqOm5B6YfjQ0uxByjNWUO5w1jFh883kT1YRDtr88ufJPhTp57T XlGQ== X-Gm-Message-State: AOJu0Yw7qI0pbKg26q4ih/FF5s3IOAitMd157h5xgaT97qrb5ek5qvEe 414XlJb2IvKXJhBcgXaAHLc= X-Received: by 2002:a17:903:124d:b0:1c5:6691:4978 with SMTP id u13-20020a170903124d00b001c566914978mr2154400plh.37.1695201156730; Wed, 20 Sep 2023 02:12:36 -0700 (PDT) Received: from mason-virtual-machine.localdomain ([43.224.245.242]) by smtp.gmail.com with ESMTPSA id c21-20020a170902c1d500b001bb8895848bsm5247792plc.71.2023.09.20.02.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 02:12:36 -0700 (PDT) From: Zhang Hui X-Google-Original-From: Zhang Hui To: alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, stanley.chu@mediatek.com, peng.zhou@mediatek.com, yujiaochen@xiaomi.com, yudongbin@xiaomi.com, zhanghui31@xiaomi.com Subject: [PATCH] scsi: ufs: core: Do not access null point in ufshpb_remove Date: Wed, 20 Sep 2023 17:12:26 +0800 Message-Id: <20230920091226.55663-1-zhanghui31@xiaomi.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,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-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 20 Sep 2023 02:12:53 -0700 (PDT) From: zhanghui If hpb is not enabled or not allowed, some points will not be allocated in init flow, so access them will trigger KE in ufshpb remove flow. Call trace in rmmod ko: destroy_workqueue+0x1c/0x234 ufshpb_remove+0x40/0x50 ufshcd_remove+0x3c/0xd0 ... Signed-off-by: zhanghui --- drivers/ufs/core/ufshpb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ufs/core/ufshpb.c b/drivers/ufs/core/ufshpb.c index 255f8b38d0c2..fa345e161cb8 100644 --- a/drivers/ufs/core/ufshpb.c +++ b/drivers/ufs/core/ufshpb.c @@ -2656,6 +2656,9 @@ void ufshpb_init(struct ufs_hba *hba) void ufshpb_remove(struct ufs_hba *hba) { + if (!ufshpb_is_allowed(hba) || !hba->dev_info.hpb_enabled) + return; + mempool_destroy(ufshpb_page_pool); mempool_destroy(ufshpb_mctx_pool); kmem_cache_destroy(ufshpb_mctx_cache); -- 2.34.1