Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4417405pxa; Mon, 10 Aug 2020 08:36:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW2vGGx8KWr3bXDVYfvrECTY9riuykFs3xz8tocMX/eILVh9E+KjGwO8SPXzWEJ0Xa1aG0 X-Received: by 2002:aa7:db59:: with SMTP id n25mr21006090edt.276.1597073789995; Mon, 10 Aug 2020 08:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597073789; cv=none; d=google.com; s=arc-20160816; b=e0Jf6B6LK2miqtldbmSSmAgdRJeAqSDO+w6lIfBGQGKDF/d++goidJq3sN3AO4qPe0 HpPGExp50phqIGubHd7/J9I5V60yXnaMcOZP5r0N+gbVYraUllTnb+qPB0uDeKj/AVAu d1zUoN1odHdySzB40WWUg5CKgCAM8MVoRut3IYUI5HzZBaLtp69THtW1QzgKPi5vRq02 DD+dcdyrTZxm0CF8Z4zE9I+BeKIwR9UnUxp4+SyXdsT08kS7ZvRiaByb4rECEU28lvbq lQkKAhb3QePCk8EnziKe54u79seo7V+32ldZLx7dE6otLs6HnOii6xqVUHfDo6+s8m9q UXZw== 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=q+H7VZwKX3LHXWHWs81s5bTQAu3jnrhpGrwUIMiFpAc=; b=Ss18B03gDiVM8laffKRcX9Je1Yw00ASa4Mps4/Soc/7KUb9Aqv/bag3Qula21oaEhq 18ZBBOsOZJ2Ys5o7w/X7A61eYK0TziTbCBWeOsp4DrUYY4yxtDXOmDnPlwQrg3ZApf+M yKEs5FNJlB4AWoWD7v2fsiQnAgoWPWP9mqVAY48henCvXuGRWQL4Um8pHUJnvBx3xwM/ n+d5bpt/uKFNl/d0NFxL06iwp5i3bSekkhIaAAXeh0histLIeRvIMO2sBvkBmvE2+BgU yY+QzQSdAmnXukxGqPq3VKeBNYWSFHLHhirAUv9MeduBT1S1ItvcbvF0GVOfj3QKUwbu nONg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MGjoNRP2; 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 z20si10932890ejm.732.2020.08.10.08.36.06; Mon, 10 Aug 2020 08:36:29 -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=MGjoNRP2; 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 S1729210AbgHJPdo (ORCPT + 99 others); Mon, 10 Aug 2020 11:33:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:36070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728974AbgHJP3g (ORCPT ); Mon, 10 Aug 2020 11:29:36 -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 1252222D06; Mon, 10 Aug 2020 15:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073375; bh=72cAI67VtDDZt1mKfeA6RIpba9BunW+7lZj51ljgIhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MGjoNRP2emTIjuR3C9RHSwWu1nivOZUtabZCko2m9l18ZihOr07ssChp+cfpf8YBM xNY3IxIVl2WiItfC7okKPLCH5qAod/x/A+2Fu6yhncwbeo3LPQP5zTadpZDXCrK9WL 4CaxFX1KbvSVnYQvopqFXQcyYl73GawIkQY4xsy4= 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 4.19 16/48] leds: da903x: fix use-after-free on unbind Date: Mon, 10 Aug 2020 17:21:38 +0200 Message-Id: <20200810151805.006523413@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151804.199494191@linuxfoundation.org> References: <20200810151804.199494191@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 @@ -113,12 +113,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; } @@ -127,6 +138,7 @@ static struct platform_driver da903x_led .name = "da903x-led", }, .probe = da903x_led_probe, + .remove = da903x_led_remove, }; module_platform_driver(da903x_led_driver);