Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4407279pxa; Mon, 10 Aug 2020 08:23:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzs4EDnO1QtIwyhecydPW38SUTz9wIPYBo8PvquNXzWNc2MO0hsCm/g5cME8uvjN2WWrRUS X-Received: by 2002:a17:906:1ed3:: with SMTP id m19mr21306811ejj.396.1597073010292; Mon, 10 Aug 2020 08:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597073010; cv=none; d=google.com; s=arc-20160816; b=f6JN3R/Y/vyLg72E66oYx9ge8CgQKIUDb+ydRl8OS9J5fe/ncGH4wiip/3G2xqG9mx m8J1yR8iIUTunooTo9bM2alYQvuY8RCb7hwAMqGgKQ8CVGn4OyKmSU7WZU/QwuMLJ8KW Ry9QaIVIkjApNnAMdrJ1YZJIHCB2KXnqFdmBViGVdvkRYfQsQ8AqvbMa+CtdMJrVe8u5 vcS+5pepAF9JBs+mM22A8Phu9VcLmCJpTH59iGJQ6JTM9Iv7HsulH4YpuVykP0oYQtGO ib0PpycvznvR7KgjNqOkpfuMSLaVLFfx58AqwLGuLTHbcN2zYr6bXp+yMHJTtJZiDGfO mTtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cGoKqAOrX7WGWrXzJLreUzDHuWDvsL7hxJhuMBfVGqQ=; b=k2LHWoQg05cEJ/PgCuzUCZgUBAGXxDAWU16fkI5Witeh7GT8kUst1xSKsL1KYOezYN QbRc+aMzR1woBu9hantzT4X26Ured614xLUa2HSlmyJPKtNQfWWL/VbKSRlpkDqHFWML JooZ84dRVcsAKAogZe8yHYH625m+9yZOksOUSHdaJYOq7LvNYTorLbpW7Ut7zQvU/N/M HozNjLylUptxt6SB+QEiHX9BrOmINA7zxi3+8wOP9uUmJcx54RvyeCqL7jKKLJddqv4r N8ROxWsR+YREXoLtxN2h+3Dktghe8vgChiY+hwomJ/VHjrXMtNpG86f41u+4eIqwgrQS AAeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ubfWQLs8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rs22si9788433ejb.751.2020.08.10.08.23.07; Mon, 10 Aug 2020 08:23:30 -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=@kernel.org header.s=default header.b=ubfWQLs8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727964AbgHJPUV (ORCPT + 99 others); Mon, 10 Aug 2020 11:20:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:50626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727956AbgHJPUR (ORCPT ); Mon, 10 Aug 2020 11:20:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75A4220772; Mon, 10 Aug 2020 15:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597072817; bh=lI6E/4lPK/biapph8fLlSw8m7Ev/Xq7lJP/iubY+u2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ubfWQLs8+T+U9PbZm1nQz58vvGokOH0Dk08tC0KvU40SHdhOqXPkvIWGetPJpO8aC EorS6q1wQGC8ZScaydoK+G/dcH0U4QY3oAxhVvLxl7sBvQ/hQzhO1oNgvGW9yGSN5T dgok6CPO0pZhwkTpfTYCvL3cqXmV2LiAqOPp3GQ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amitoj Kaur Chawla , Johan Hovold , Pavel Machek Subject: [PATCH 5.8 28/38] leds: lm3533: fix use-after-free on unbind Date: Mon, 10 Aug 2020 17:19:18 +0200 Message-Id: <20200810151805.287213549@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151803.920113428@linuxfoundation.org> References: <20200810151803.920113428@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit d584221e683bbd173738603b83a315f27d27d043 upstream. Several MFD child drivers register their class devices directly under the parent device. This means you cannot blindly do devres conversions so that deregistration ends up being tied to the parent device, something which leads to use-after-free on driver unbind when the class device is released while still being registered. Fixes: 50154e29e5cc ("leds: lm3533: Use devm_led_classdev_register") Cc: stable # 4.6 Cc: Amitoj Kaur Chawla Signed-off-by: Johan Hovold Signed-off-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- drivers/leds/leds-lm3533.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/drivers/leds/leds-lm3533.c +++ b/drivers/leds/leds-lm3533.c @@ -694,7 +694,7 @@ static int lm3533_led_probe(struct platf platform_set_drvdata(pdev, led); - ret = devm_led_classdev_register(pdev->dev.parent, &led->cdev); + ret = led_classdev_register(pdev->dev.parent, &led->cdev); if (ret) { dev_err(&pdev->dev, "failed to register LED %d\n", pdev->id); return ret; @@ -704,13 +704,18 @@ static int lm3533_led_probe(struct platf ret = lm3533_led_setup(led, pdata); if (ret) - return ret; + goto err_deregister; ret = lm3533_ctrlbank_enable(&led->cb); if (ret) - return ret; + goto err_deregister; return 0; + +err_deregister: + led_classdev_unregister(&led->cdev); + + return ret; } static int lm3533_led_remove(struct platform_device *pdev) @@ -720,6 +725,7 @@ static int lm3533_led_remove(struct plat dev_dbg(&pdev->dev, "%s\n", __func__); lm3533_ctrlbank_disable(&led->cb); + led_classdev_unregister(&led->cdev); return 0; }