Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3025166pxb; Mon, 18 Oct 2021 06:50:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUZQBf8i6ZB3Rm7bf+TJ1b++pXydwacuqumCX+QFaSEwCYLpmSevPxidZGJcojOWGek/IA X-Received: by 2002:a17:902:e848:b0:13e:f908:155a with SMTP id t8-20020a170902e84800b0013ef908155amr27697164plg.13.1634565059747; Mon, 18 Oct 2021 06:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565059; cv=none; d=google.com; s=arc-20160816; b=P8LxBBjMFfEYgL/0OlTVNkEl/Mrf8nCFSel+aCIzxMlUrlZUu+IfdS0y59oJQLZcdr ZpOZa38YoMRw2h8RlnNlVEA1vkCdDS2u1ornUA4fNT22i8IzK88xD6d4rJ8VjWLAjzMx OW2iVXUQheo4pLZeanLtXiL5aUbaTuLMr1iiQU1ThntkMGDSSNmwBYhQO+TLkA8pszqH crBc4HAD8AeNN+wDkuhC3kY+qJr9D2vUvNvLlfEyrH6tVuXue5RSH2KEOmloBB099prd nx+CtV6vMSDUycioAB23e+zv5k343MM9q1vcJkENnW+glzGdtWFCw1HTTwAeQVDJUxKs fsZA== 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=TkzL4tePWg3BRVmODYph2QiLHlLgOIJED7BPxbXhcP6f9Z4li3t3lZDHKxNGn5LrVC dGe732SYnz7ofy0y2q8gexKISD6BfXFixFnkuFRyWJVFiJqfQ32MMcACyD6mf4Ssj1Cs yR4ftrQFtBh0YaPkHXeOMZkGcmBa/fNPlyEDtJQ/V1QNgNJABSoZDs37KMqiyD29IOFC bJryuvxf/vdoMqnprVV1Db+kF4wx/TK69M00GNFC3r0lUAHLTSaGj8hmfU0YAFiWESqC XfIFkFAyHYR8JxQ2Tr/OhyVBxSc7ChRk1V8dfKuysUa9jUy6FrsqovgZP+CJjnoxKztA E9ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=U11Tiu4f; 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 g1si20615263pjl.47.2021.10.18.06.50.47; Mon, 18 Oct 2021 06:50:59 -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=U11Tiu4f; 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 S233927AbhJRNuF (ORCPT + 99 others); Mon, 18 Oct 2021 09:50:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:50494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233967AbhJRNsQ (ORCPT ); Mon, 18 Oct 2021 09:48:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1C263617E3; Mon, 18 Oct 2021 13:36:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564209; bh=hdVSouO5q40i5sExSswgZBr9F2tSWw0r0jMFgRHJJXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U11Tiu4fq9u8dIEiXNaAhgJZyrwrX+f8P6/mM/QUd5MC+0WMSKo7RbdlZ2t2tjI/m BE2s8P8n6vIN6S6QU6Y4s16ehsldObWA2mY0sFvsgfZejLTgZ7G4bjG2WFu4VDif81 c/NE07hyClLzGVmTEZwkE+bIWF574PQDzCq2A+yM= 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.10 083/103] ata: ahci_platform: fix null-ptr-deref in ahci_platform_enable_regulators() Date: Mon, 18 Oct 2021 15:24:59 +0200 Message-Id: <20211018132337.545305044@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132334.702559133@linuxfoundation.org> References: <20211018132334.702559133@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) {