Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3016357pxb; Mon, 18 Oct 2021 06:40:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8aw9zEvPW8rlJxZPDzrfaMtJwx85/R/BRrVlGYD2ZOYJc0nfO4PygNiL9qptmmsIKIWcc X-Received: by 2002:a05:6a00:1686:b0:44d:50e:de9e with SMTP id k6-20020a056a00168600b0044d050ede9emr29362108pfc.4.1634564412298; Mon, 18 Oct 2021 06:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564412; cv=none; d=google.com; s=arc-20160816; b=icC7yC7XFaxRQ885fk+YWWeM5xGY084qTSGqx+iItluAVr5Pfzbpp21+hr8oyPLCJ6 NPNREyTvrqxg0UjHHkcpxg8ODHGu54l2ORxuAT0CRnbWfx2EIkbUQBQmrsB3RXfvyHkV 0btMtPymT/HRfOpZhrrB2+g+bddPddUh3cVgIMrBzsliePVhDsT23zDv7NgbCibxv0OV 7biBs+l5TIYWL8W1km9yyCdrS2/Rd0SkbId/SGNwwKBQe6PPKtBBerYLUw+MleuSKPv2 IxRyAq/PUU78sLWuLiNnF52v8T/o4htT9Tx7wz8q6evIl7XnYqMdHmEAUnrt4fEG+LSA sWYA== 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=XHCQWpQSUD+ZgoPC884OSP3gQh4mi4qXr9FShHEFVC7FfSAFCW6iQfIydT0NTnQJRj PnFFdr8cCrv9HKXOYkggEUrxg5gldZZd+GF4XVv7SiUH8C6PiwbCb+BdzrauUB4mvcA2 TuNCHqdbva2FIIOgb7PeIRsXfu9h0v9rTp874Zaz9VMzz45AM+86kM1ECraBv+uv6QyV LqSTbwLL051KlEdxDt0o+UfmFa/vYoN3eSRijWLqCT6brADyPUsDgxeEDFc2VVmRSbW7 BeJeU6WiLmjsml861/WnxgY9/Lvn/gvgG4avzOt2wzpUauvP/yDudAqQkxLo6rPuCirw Do4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="mJlB/Vpm"; 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 b18si29028271pgn.107.2021.10.18.06.39.59; Mon, 18 Oct 2021 06:40:12 -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="mJlB/Vpm"; 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 S233070AbhJRNk5 (ORCPT + 99 others); Mon, 18 Oct 2021 09:40:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:54084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233835AbhJRNix (ORCPT ); Mon, 18 Oct 2021 09:38:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CAADB613A3; Mon, 18 Oct 2021 13:32:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563943; bh=hdVSouO5q40i5sExSswgZBr9F2tSWw0r0jMFgRHJJXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mJlB/Vpm0mcBo4NymixLL4TOUo29keBk7P2v13bjdT7dw4y3ntU1o8UicrYXGhk8k WbEIV+R8xOUM/UBAR9v1+ObiTjy60Nwc+UkQ/xn0AdBIby+r6zuI5jnm1tZASbnits 1YQxGoAIGgdyaK3xfBf1Yxj/AC4lOc4Xq2cfqDV0= 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.4 57/69] ata: ahci_platform: fix null-ptr-deref in ahci_platform_enable_regulators() Date: Mon, 18 Oct 2021 15:24:55 +0200 Message-Id: <20211018132331.363394702@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@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) {