Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4408725pxa; Mon, 10 Aug 2020 08:25:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpbe50VBv4jJILU7jO+TsNkpLctj1Du2e42HhiMGp7NGnkF5O8JqXnSevrbwqHt9/41eHW X-Received: by 2002:aa7:da04:: with SMTP id r4mr20838229eds.265.1597073124654; Mon, 10 Aug 2020 08:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597073124; cv=none; d=google.com; s=arc-20160816; b=iq3ZpCzxZ0PDSVfzC2ckqnHsiKK9LMaWFVRiMxeJK7TeEICjTNNO2qaj9xAVypXHys xN/vg36L9H2n/nZ4TvuiDd6rhRkKohyZQM+AsFQFOA/h6Go/KVM840NcbPfQoquF7W1B EK6g5jruwO6JCcdhDIzhAD4tReCse2OrDVHuFIL19+SF/V++aAcr7FWA4EsmHDa/U4mp Bz/QdB6oD849XPodl52C9gZi+oPgAp0gDaoXrjIrewUeLdGSZNgoZjxlLXPDllOeg0+j CiZrKvIv1NMoayYR2f6PfQiTZlrwdsnuxHHzRztDMM3tEZMd5JN5slboqct9EIU7x2ua K5MQ== 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=gAtSknEFCF5eBOrlWxg+FCoD//0efne1dStZh13W468=; b=W7Lkj82N7XZ9FnNsKIrfuLWp/MoV1J4kYpFaaKmZ16ZIMXOT785fhwrcjyS5FSrRem g9uNBO7mWD5jayYG3Ryx3CAMUdmiNYxdq/FMuRSDwh2FD4OUACbym0wLA4vCdSgu9Ok5 HilYS85A0HHJ93d/+JOEUP9cS3R0C4oVvd8XF3ZNlbqEd5JJMrt9rnIWcNW8tUXpPduA wxY7XzllfltLDo8AXxQ9bWRxgk9vpZPGnnS0NDRCG9M1lR7lef4qIYB/taIxY5e+IcEL z9MuoRXrmw2eNzTbQqvL6DrcfA+Ocz8eAB7Z0sTXme145RnqA/aNXEi+YPYIG9hZehxt huMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f+2fOlym; 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 d23si9993002edp.84.2020.08.10.08.25.01; Mon, 10 Aug 2020 08:25:24 -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=f+2fOlym; 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 S1728200AbgHJPVv (ORCPT + 99 others); Mon, 10 Aug 2020 11:21:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:50696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727959AbgHJPUU (ORCPT ); Mon, 10 Aug 2020 11:20:20 -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 4A9CA22B4B; Mon, 10 Aug 2020 15:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597072819; bh=OI8L8JHWA4I07xOnOfrugVYN6Wsn1SSxQOR6XVPL8Yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f+2fOlymb0QreXYIqA2Sgux9MBcFmFDnWobQL74jI4/4PZ2o93Oxkmnjhj++cKTeE ecSX1m7as7atZHsbCJH49A7/nrpxSGkSiZd03rQ/R8BBbpvAQCmfA6yYzGr2zb2kyB bFZ9Z4VMW6Z6rUMPVLJxjO14JzN9p5rixWK3MAKo= 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 29/38] leds: 88pm860x: fix use-after-free on unbind Date: Mon, 10 Aug 2020 17:19:19 +0200 Message-Id: <20200810151805.342635725@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 eca21c2d8655387823d695b26e6fe78cf3975c05 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: 375446df95ee ("leds: 88pm860x: 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-88pm860x.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) --- a/drivers/leds/leds-88pm860x.c +++ b/drivers/leds/leds-88pm860x.c @@ -203,21 +203,33 @@ static int pm860x_led_probe(struct platf data->cdev.brightness_set_blocking = pm860x_led_set; mutex_init(&data->lock); - ret = devm_led_classdev_register(chip->dev, &data->cdev); + ret = led_classdev_register(chip->dev, &data->cdev); if (ret < 0) { dev_err(&pdev->dev, "Failed to register LED: %d\n", ret); return ret; } pm860x_led_set(&data->cdev, 0); + + platform_set_drvdata(pdev, data); + return 0; } +static int pm860x_led_remove(struct platform_device *pdev) +{ + struct pm860x_led *data = platform_get_drvdata(pdev); + + led_classdev_unregister(&data->cdev); + + return 0; +} static struct platform_driver pm860x_led_driver = { .driver = { .name = "88pm860x-led", }, .probe = pm860x_led_probe, + .remove = pm860x_led_remove, }; module_platform_driver(pm860x_led_driver);