Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp421606lqi; Thu, 7 Mar 2024 00:53:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXOAfvJNAYP2oFTu2V9sbbA4yDfT25lSJSdBpakgqApoAOLLAEO3bQdjdxLIIdspb5xUBjNm0Aj3JMe/CHOtE7dLOlZnsyjhfGGGYsQKA== X-Google-Smtp-Source: AGHT+IEQ/MpxsT17ZlNMbNcCI6nybYU8AlY+6q6UPp/lgmC2I7Km418eEBr3NdreGHyS7MoCgVKN X-Received: by 2002:a9d:63d0:0:b0:6e5:c4d:89b7 with SMTP id e16-20020a9d63d0000000b006e50c4d89b7mr95829otl.14.1709801635569; Thu, 07 Mar 2024 00:53:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709801635; cv=pass; d=google.com; s=arc-20160816; b=JXEMjXTRamEH8n8plYFn+6Jdk1KTASndVxks62eZkqODVHgUL0WiMfVcaoNfUSXjQa lU6p67AKN6dmNLMZ0Fp15xx1nbn0JYiQaC8hTpoo/OHUVNQiUvfQVVEE6KWBryyL48Cs i+zXPBPAWYWGxfP0CncD7TFGVu7QDlH3wB8EYXu43+og3cAJgSvk3xiSUKYnUeomuW/N x7NCZJE2RY6MtzciF8DtCkOziJoHpX7ccmJYNMMdYJoFldDQ++UK9c7zQt2+6rXV5Lgr 4Yym6obPLIAi+h8ST6z5J7bHgMZe1UsIf8ZrmFfl5LzKspl60iLunz6cdj9A3jweYzGY 2WsA== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=IYuDKE6wcngSlBLZHMJobm5rVJjSjgr3vxQlOD53g1c=; fh=Z84Iw7ES52Gu5fNiBdta2mjkEVAacsSHHRs+v5i4D5Q=; b=LVC5tryeAyaXT9oqh9immLGvkOqPtI2d1y6vknExAdP3FyVCm21vgiJjdSBGR/bgb6 5EoZ7FLKyJ25Uo1r7YRjLkD+Zrue1Y/x4++H8HBY25ReXZRUlwdp/QXW19DIsYf470lc 6BgjobjhF7OB98ANTIvtTMdLEktIDd/EXZ7Kpi8WwMFXufBJE2BDxEYW8/TAm6b3e1iE XfFbfGbGHp1eiX5TcTqSvAeit6G6460MNyaITzsMXbTjHbmmEtjs7L3F9G4ED6TWnmOj fyI4IlU1qm5Yk/DrKemLyGiebn0o/G3zloN2T1UxUVkVltUinK8PzfBTSzyzrUhxj5dt UYbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=rMyCNR0z; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-95164-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id cb4-20020a056a02070400b005e42fc7a15asi14838483pgb.348.2024.03.07.00.53.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 00:53:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95164-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=rMyCNR0z; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-95164-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95164-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3A7FE2857EC for ; Thu, 7 Mar 2024 08:53:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EDB3F82D7C; Thu, 7 Mar 2024 08:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b="rMyCNR0z" Received: from mx1.t-argos.ru (mx1.t-argos.ru [109.73.34.58]) (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 8A1BB1A29A; Thu, 7 Mar 2024 08:53:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.73.34.58 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709801629; cv=none; b=KAfWoEzzes8lcVkhShTNGtWQZvBhyVXxB4Y4BjHYnQBSysdIv1vFjZBgg1sh/Vx3PrUamOu3yC1jk7bX6mdpIdQhqPYr98iePf2y/VP550D5qlk7xuk7oAa0gT6AhNXz3Ow0h/wKmFxEi5kz4xU1NiuwQeuRxG+ThRac2ZLuNKY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709801629; c=relaxed/simple; bh=apfVStlB67TMYQsd9dI7ItflrhUjMPLZgwzzdIWFtL0=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=JeQC9y7NwTGi93dj53b00McRUMHXNAj1DMjGYNm78kv8ngDN38HnuD2GVUaM71UXm2MOEHbvsb1cjV5WdnG9JbaEWaIissl5AiRlvhaQEKtq9Z5SJGfHE8Tc3wXUJQuEJwrcgWOW0NZ+7J9qm73Kcop+S5u3JYK/mJ283rZpdfc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru; spf=pass smtp.mailfrom=t-argos.ru; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b=rMyCNR0z; arc=none smtp.client-ip=109.73.34.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=t-argos.ru Received: from mx1.t-argos.ru (localhost [127.0.0.1]) by mx1.t-argos.ru (Postfix) with ESMTP id 36461100003; Thu, 7 Mar 2024 11:53:26 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=t-argos.ru; s=mail; t=1709801606; bh=IYuDKE6wcngSlBLZHMJobm5rVJjSjgr3vxQlOD53g1c=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=rMyCNR0zFhyLlOc2MRl+YKdk76rC3tIWU7SmtOaCalG+XTYZw/8E5Y4bzYfcd8WlG OUvmt2zp7eW1m7MFCjrx5F5enQo4rgjRUFmOobF+4jIiyUx9DcWDaLeJX11EFZ82rY 5QBR+mPzNK5EbxL4jIaAOC+Ms8dDSJzs2KFMcfYjytLm8ySjeT62Sw53ypmwQy4VsG KtxFpJAFHha6QTsp7YjJb6OI7btwFvsaihxwappOwcDH0bDHgajQoRhMlXR/7SUirP e8qOCOHEtPGj2eN8b27A+rVgYo6UQU2HU2LkXTer6jFOwgQEcIapgGZjWA2rSS4e/K XfPUchdodPZTQ== Received: from mx1.t-argos.ru.ru (mail.t-argos.ru [172.17.13.212]) by mx1.t-argos.ru (Postfix) with ESMTP; Thu, 7 Mar 2024 11:52:45 +0300 (MSK) Received: from localhost.localdomain (172.17.215.6) by ta-mail-02 (172.17.13.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 7 Mar 2024 11:51:53 +0300 From: Aleksandr Mishin To: Jaehoon Chung CC: Aleksandr Mishin , Ulf Hansson , Wen Zhiwei , , , Subject: [PATCH] mmc: dw_mmc: Fix potential null pointer risk Date: Thu, 7 Mar 2024 11:51:35 +0300 Message-ID: <20240307085135.16245-1-amishin@t-argos.ru> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: ta-mail-02.ta.t-argos.ru (172.17.13.212) To ta-mail-02 (172.17.13.212) X-KSMG-Rule-ID: 1 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184022 [Mar 07 2024] X-KSMG-AntiSpam-Version: 6.1.0.3 X-KSMG-AntiSpam-Envelope-From: amishin@t-argos.ru X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 9 0.3.9 e923e63e431b6489f12901471775b2d1b59df0ba, {Tracking_from_domain_doesnt_match_to}, 127.0.0.199:7.1.2;mx1.t-argos.ru.ru:7.1.1;t-argos.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1, FromAlignment: s X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean, bases: 2024/03/07 07:53:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2024/03/07 06:26:00 #24026065 X-KSMG-AntiVirus-Status: Clean, skipped In dw_mci_runtime_resume() 'host->slot' could be null, but check is not cover all corresponding code. Fix this bug by changing check place. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 4a835afd808a (mmc: dw_mmc: Fix potential null pointer risk) Signed-off-by: Aleksandr Mishin --- drivers/mmc/host/dw_mmc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 829af2c98a44..a4f124452abc 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -3570,8 +3570,10 @@ int dw_mci_runtime_resume(struct device *dev) DW_MCI_ERROR_FLAGS); mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); + if (!host->slot) + goto err; - if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER) + if (host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER) dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios); /* Force setup bus to guarantee available clock output */ -- 2.30.2