From nobody Sat Feb 7 20:10:15 2026 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1E1B31196A for ; Thu, 11 Dec 2025 16:15:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765469729; cv=none; b=IpiKfGY7wFfD9RE1Wi2kBrQcAjgB6r/cFfa+Kk/Ypbz+J/6i1rHD87hqSgVeVAoYXLxj6/CNB/tv/ESDRYeLK1i5I3iTnamsdYTaQbzF1KMqcKU1cJymu6GZTgPGI+cy6CPME3zCCUsvDVH3F93L224hUrk4/nCXlIhsCt1f9nM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765469729; c=relaxed/simple; bh=9MHv9U+sIP0p9WbV7pGkyb6FAUYdsK4jABeRipv6wcM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=butVnKrXSiKf+VzPYe0ESXcLZSjyxE4Etxjmjg41L2bi0T/WERyOkn7z7K5O9ufm6sSwO3848opuxHEeE/t6+jUchpe9ZJJjN1/NUEe+q/wc/tzI+xv+9ru4Bfsd7dMG95as6IAj5kBSG6BiP7rFcHSTC9+fNWJNfONDkmCsUEI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=COqC7Cju; arc=none smtp.client-ip=209.85.216.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="COqC7Cju" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-341988c720aso202605a91.3 for ; Thu, 11 Dec 2025 08:15:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765469727; x=1766074527; 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=gGzmMUNNAOJwEedQ/rguOQmtJ7RZS/q2FSqGY6vneBc=; b=COqC7CjukVkf+m2i2tpunrqLfzxYYxKM5ugJQDfX2noDCioGeLDLet+uYz9mXFkf8M qW9K68EC15fi9X46WMgNNQys5H4Znxa8dgmIwODbRCF1/9GnPE45hR41+fVp44+/RpQ7 jtVktWIxMWRRAdL372lNaSeQktEyqc3PBZa2zrDGlJA2U8RWYdXg4JMBLj0yxSGS1/67 6RfIbIEvlu1CrJZ3dcTLtPpV6rU3eeTse9eWSAqij8MwdH+9IXM9uwSYN9lS9pPWdCm/ GcBEXKWB06hZUt8EAvW1u28g5v7h6POJ4vsey6ZjNT+XiSw1a5WD7OefVrVi6wBWDyZO Qb0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765469727; x=1766074527; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gGzmMUNNAOJwEedQ/rguOQmtJ7RZS/q2FSqGY6vneBc=; b=M8C7OX6lF78psdTaYYNlLEq/z55rNpSnB5m9gkBm3PPq4GaS7gzBQqRp4V1eYSEMgQ 6BPiMwLGo+MqH7xwBwzyy7w5rafXOhQi+HvpqePSjUcXjTqYzCkAwolH8rRwZPxbBaig Rj7sSbW0eUwIL4U1zWBtbWa3nHVcNG/2JEl9aMm5AmhMQ+LlIrrozfWEdCw/BFizNE+x L6PuYpPQQ6GpwpBM/bg/nR55RvoRSTsFpRfjkrVdZhG9ovwGg7MWYxaCRP2VXS8hj9Fv 7XXYCeZylrgCyNPDFig9W7pnL0JwVvDZ8H6HJ9m5jiaJTeM8+pd8GJIAwNl3ignWBkNO kYxg== X-Forwarded-Encrypted: i=1; AJvYcCW6H2xLJSKyvFZEZXU07HCrqn/e1Mm+Dk10TaDDXd+U1HqVgNHniiPxx4TgrHwc+7L9QaYLKQnTzcCmAww=@vger.kernel.org X-Gm-Message-State: AOJu0YyGXPLKfMlN3j8hvKe1UyJ2dH6tQR0ofBNB8MRLMpox0oAphqLs Md3ctfvw8N1CcWeCsvPc5RvILDe1/sCr0teI1Pj2uXeaNiMmVrBwC7xO X-Gm-Gg: AY/fxX6xbFVPvGY1w6fGRamgCPvH5SoAIUTBZKm3ju1Rp4U8ztBEBZ0zWzApg8K0ntE RU62Z2ogRMwm+7GYZBrW4zyUuVfB9Jiio1NhpuxywcyEKscLZdU9mzAjKa0F+Fvzoqlij/KKsWl /8kXQ0uPW8+nnrzLuRToAVrRuMcoqH9FmhaYnGqKgT8Ij5NzqKHvPgjTFNi1SM0YSxoXTSRzcSk 7ckSRV05e8xJzE9Em4KWj/FKHe1iqMKTRzhGHOrbfNlAOzNs+WEC1lusDH5BU7C6GlchSU0Oxzd z5QZSBRipO3K0QRlW2eQgzffkZQPFqtLWrCyvZUDywvKofUt/vxf4b2As0hnTM0SBSC87S952e9 H4n77JR1Hh195hMUpqi2obRZ1oA4W2BLr2aTmg0QLnVkmqzgqbd9udfgts49Zz9izdWNc36jJpp wGcxknuc2ggR7AK5NyKhuOxFPA7KN+nyaW7xAchcGd1eAsTuLqRzrtSdUxPKmVfbXYBYOG5vQgl w== X-Google-Smtp-Source: AGHT+IFQsCDlcvlCMimDFjXBthrDJntLJez/5kfiB+AqUFY15dTXUsOpWGzg5GS8BJRyVlbv8+e0jA== X-Received: by 2002:a17:90b:4b8f:b0:34a:aa7b:1af8 with SMTP id 98e67ed59e1d1-34aaa7b1cd5mr660661a91.32.1765469726837; Thu, 11 Dec 2025 08:15:26 -0800 (PST) Received: from oslab.. (n058152119183.netvigator.com. [58.152.119.183]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c0c25a86fa3sm2791188a12.5.2025.12.11.08.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 08:15:26 -0800 (PST) From: Tuo Li To: jh80.chung@samsung.com, shawn.lin@rock-chips.com, ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Tuo Li Subject: [PATCH] mmc: dw_mmc: Add a defensive check to prevent potential null-pointer dereferences in dw_mci_runtime_resume() Date: Fri, 12 Dec 2025 00:13:13 +0800 Message-ID: <20251211161313.3994317-1-islituo@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In this function, the variable host->slot is checked and then dereferenced in several places which indicates it can be NULL, for example: if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER) dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios); However, in the following cases, host->slot is dereferenced without a preceding NULL check, which introduces a risk of null-pointer dereference: dw_mci_setup_bus(host->slot, true); if (sdio_irq_claimed(host->slot->mmc)) __dw_mci_enable_sdio_irq(host->slot, 1); dw_mci_enable_cd(host); To prevent such issues, add a defensive check to ensure host->slot is not NULL before dereferencing it. Signed-off-by: Tuo Li --- drivers/mmc/host/dw_mmc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 9e74b675e92d..e74dea0a32d4 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -3670,15 +3670,18 @@ int dw_mci_runtime_resume(struct device *dev) if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER) dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios); =20 - /* Force setup bus to guarantee available clock output */ - dw_mci_setup_bus(host->slot, true); =20 - /* Re-enable SDIO interrupts. */ - if (sdio_irq_claimed(host->slot->mmc)) - __dw_mci_enable_sdio_irq(host->slot, 1); + if (host->slot) { + /* Force setup bus to guarantee available clock output */ + dw_mci_setup_bus(host->slot, true); =20 - /* Now that slots are all setup, we can enable card detect */ - dw_mci_enable_cd(host); + /* Re-enable SDIO interrupts. */ + if (sdio_irq_claimed(host->slot->mmc)) + __dw_mci_enable_sdio_irq(host->slot, 1); + + /* Now that slots are all setup, we can enable card detect */ + dw_mci_enable_cd(host); + } =20 return 0; =20 --=20 2.43.0