Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3036267pxb; Mon, 18 Oct 2021 07:03:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXzTimuaynuTckADk1xXPDUZcqq/w984wJvWCTR4qpyt04ASjK7RLbjnRcPjUZFs7MRHOS X-Received: by 2002:a05:6000:1acc:: with SMTP id i12mr35336884wry.249.1634565832434; Mon, 18 Oct 2021 07:03:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565832; cv=none; d=google.com; s=arc-20160816; b=ykdngrfRfeA13sZDRAprLsFLJ2Rq1WfWS8U5ZCcMMiJO52sjplp8HiJUjXyQCTdmsq 1kX11oorWu6SVBJHUp5WPQdXXk/evp4jtNyyo0qzHNQ+ikLas/zJs3cGUinzYfVpLv9i nfLDhVHUodbzHzrm5jh5sVLMIbmsx5b0aevpVx51aNlkp12Hj/Ef37h9K05tXWu50sTz wQ4D5Mj/lVIWk66ILywfzCpr5xwMl7TwOkrSaDhk7PuXnTX3L7wdduxMDoFXL7oM5Ehk z5vejqAH3hzKZlaSUdUWovbJlr96SxdWo7a/qFrcsVrKQQC3Cus4PwVZKYHGKFCP/SUL N2hw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f9J31xz9IYuS7H2fl2LX29XaTN8V/MwGhYiKscNi4Oc=; b=cN7qKdahiRnFlPRugfuLYSUwAL+nfDm4mXp8JdzIRknhEDF5b2FQ2LGyKUVgpL5Pmk PFTrVckdQm5OI9uf/BDhkW+1FLJm3emODryDarRRlScIyWSuneY6RoYt9jiQr91biWuX RP5YXuw/uM9VYDcWnQ2lzjXwuDKeC4e5wLTfaKJG636CwDKeR06flA9rO9g4LQX5lwQH kEqpZzfZYHSzbHUHZplXuudfq+KdsLRTHkeu7CTmLmXc+oUQmQGJk+5KAs5uB1cr7zCL KfP3w+CdpuRZ0f6EOi+s/UnPN2awcb6UaDvApo/1d4br4uvUSRpViVVSNGN68nLSRfGq insA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HY2BbWif; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga24si24241883ejc.153.2021.10.18.07.03.25; Mon, 18 Oct 2021 07:03:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HY2BbWif; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232543AbhJROBp (ORCPT + 99 others); Mon, 18 Oct 2021 10:01:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:40702 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234098AbhJRN7y (ORCPT ); Mon, 18 Oct 2021 09:59:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1791B61A4E; Mon, 18 Oct 2021 13:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564515; bh=hdVSouO5q40i5sExSswgZBr9F2tSWw0r0jMFgRHJJXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HY2BbWifdQJaRU5WR/hlsALI7Go7GjcWt6S8aZtSD/GJS4vF8uhXCuKrYqS9U1wxo 7gwmVPP4aztaw/qpWN3Qm3Slj5uWKfulQXXtOmgj6K9iGqL2i6gyfWGWR/khYhU8CA 4dLkVtyitQEC2nT5h31IzJ9EqgipDLFMDoDOGhZY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Wang Hai , Hans de Goede , Damien Le Moal Subject: [PATCH 5.14 119/151] ata: ahci_platform: fix null-ptr-deref in ahci_platform_enable_regulators() Date: Mon, 18 Oct 2021 15:24:58 +0200 Message-Id: <20211018132344.540656488@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wang Hai commit 776c75010803849c1cc4f11031a2b3960ab05202 upstream. I got a null-ptr-deref report: KASAN: null-ptr-deref in range [0x0000000000000090-0x0000000000000097] ... RIP: 0010:regulator_enable+0x84/0x260 ... Call Trace: ahci_platform_enable_regulators+0xae/0x320 ahci_platform_enable_resources+0x1a/0x120 ahci_probe+0x4f/0x1b9 platform_probe+0x10b/0x280 ... entry_SYSCALL_64_after_hwframe+0x44/0xae If devm_regulator_get() in ahci_platform_get_resources() fails, hpriv->phy_regulator will point to NULL, when enabling or disabling it, null-ptr-deref will occur. ahci_probe() ahci_platform_get_resources() devm_regulator_get(, "phy") // failed, let phy_regulator = NULL ahci_platform_enable_resources() ahci_platform_enable_regulators() regulator_enable(hpriv->phy_regulator) // null-ptr-deref commit 962399bb7fbf ("ata: libahci_platform: Fix regulator_get_optional() misuse") replaces devm_regulator_get_optional() with devm_regulator_get(), but PHY regulator omits to delete "hpriv->phy_regulator = NULL;" like AHCI. Delete it like AHCI regulator to fix this bug. Fixes: commit 962399bb7fbf ("ata: libahci_platform: Fix regulator_get_optional() misuse") Reported-by: Hulk Robot Signed-off-by: Wang Hai Reviewed-by: Hans de Goede Signed-off-by: Damien Le Moal Signed-off-by: Greg Kroah-Hartman --- drivers/ata/libahci_platform.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -440,10 +440,7 @@ struct ahci_host_priv *ahci_platform_get hpriv->phy_regulator = devm_regulator_get(dev, "phy"); if (IS_ERR(hpriv->phy_regulator)) { rc = PTR_ERR(hpriv->phy_regulator); - if (rc == -EPROBE_DEFER) - goto err_out; - rc = 0; - hpriv->phy_regulator = NULL; + goto err_out; } if (flags & AHCI_PLATFORM_GET_RESETS) {