Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4406185pxa; Mon, 10 Aug 2020 08:22:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoYC0xscVxhKg+SlcnpGHOm2d+yTur9KPNWTAjarDpW7YdQvAIugF0CwxG6wrG8Qs4B4S4 X-Received: by 2002:a05:6402:1a54:: with SMTP id bf20mr21799118edb.217.1597072928092; Mon, 10 Aug 2020 08:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597072928; cv=none; d=google.com; s=arc-20160816; b=x70q0XCt3n7ySVjyf9X1UZUaihk7A3dPVyTB+/J44I0Q060TJfhMcp5RmOi0ZduDQ0 TOOAWNzIBHchb2TidSomIsPjgWWwM1Aq5VvElDEZEZIsVoN95+2CZlhcKDTvvKgx0zUe 7fJ7cxogQgmclofm1uC5RIfYXCIC5hWRShI6JdVpGFHTmMe4ElCCAhjUy9u8ZvJ4oRLM +UryNVFrW8aAT0+sYn59Vc4ADbJJ/eyL+L2UQF7KWAmQKDgXMURNji5RBXPOeK+qyOMR Ko3eCVBR8DjqzEzJm6FwTRRVeuk3/c9C1+6iowox7IsAmfcUXbRTNUgjZ8guTihd/MXl U5ow== 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=gBUrTinW7E5F8NVBIchiqhW/oS1XlKeXV9FDtLlqsH4=; b=EvOtsSoQ9LmeQ1L8I5XR7t6F8eWk5Ga4GaLIvhq4s7TxevTlo3zSUUipvPvoUuDaWM 1biF6hMcygtDzy+loACrPRHHFLVjkYtfIumWCTpauuMKGoHG801iFxrbRTFKectApneu Pw8JtUCcjTzQV1P6nWm249VdWESVjQRBKznF27xbiHyM6tv83yA8yHX8unXc76Jfbh/J BFRVz8vAh6y1qNiv7qjb8xHpVZ/ceLhWIlL2HsML15Y0WHpfAkfVhKVjBRAAcdV68dH6 KPle2WMLS1LPhUow9Qwkriiuv+vT2aX3Xd1s3HTAEjW+Y09EhRcu/7JHAT2jO9ai5dsC pShA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UrS2M9K5; 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 bo27si10757035edb.0.2020.08.10.08.21.44; Mon, 10 Aug 2020 08:22:08 -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=UrS2M9K5; 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 S1727893AbgHJPUZ (ORCPT + 99 others); Mon, 10 Aug 2020 11:20:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:50556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727945AbgHJPUO (ORCPT ); Mon, 10 Aug 2020 11:20:14 -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 86F4522B4B; Mon, 10 Aug 2020 15:20:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597072814; bh=AGOMaizvFy9TjsAgvMYtf9C1QGamiHd6Zvyz19yNHMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UrS2M9K5wC6B+UL/lXGqC5ZYPhbwKjOQtWGLfQMaE12BtZaX6X3CmmlAHg7qMnndf Noy1jh8GlB+XMRCW1/hIO6Zb1HaKfueGEmwODLR36IwLJYxHgZS7IwhbR+vzVwG5n1 hjVpQV4wAHoxu9A5lVIqmaIT4j5zV98VcUDB6Q6I= 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 27/38] leds: da903x: fix use-after-free on unbind Date: Mon, 10 Aug 2020 17:19:17 +0200 Message-Id: <20200810151805.236512093@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 6f4aa35744f69ed9b0bf5a736c9ca9b44bc1dcea 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: eed16255d66b ("leds: da903x: 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-da903x.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) --- a/drivers/leds/leds-da903x.c +++ b/drivers/leds/leds-da903x.c @@ -110,12 +110,23 @@ static int da903x_led_probe(struct platf led->flags = pdata->flags; led->master = pdev->dev.parent; - ret = devm_led_classdev_register(led->master, &led->cdev); + ret = led_classdev_register(led->master, &led->cdev); if (ret) { dev_err(&pdev->dev, "failed to register LED %d\n", id); return ret; } + platform_set_drvdata(pdev, led); + + return 0; +} + +static int da903x_led_remove(struct platform_device *pdev) +{ + struct da903x_led *led = platform_get_drvdata(pdev); + + led_classdev_unregister(&led->cdev); + return 0; } @@ -124,6 +135,7 @@ static struct platform_driver da903x_led .name = "da903x-led", }, .probe = da903x_led_probe, + .remove = da903x_led_remove, }; module_platform_driver(da903x_led_driver);