Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp478576pxx; Wed, 28 Oct 2020 09:14:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTo5jXZ7ChdgIbUhPVpBX/rE/xbnrIf6F4fSfm2p/k5ban3InT+e1eDf2AK067JXrfjIEf X-Received: by 2002:a17:906:8058:: with SMTP id x24mr3323277ejw.272.1603901663993; Wed, 28 Oct 2020 09:14:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603901663; cv=none; d=google.com; s=arc-20160816; b=nOu83n4NOq9HzLTcrvCZobXjROzNPKKPjQjBn8o8pi6Dr9yFK3GycdnYnyRzIkXTp1 60yfXb7PfceOIwGvUgQpYlVsS4O4xcTW+bd1+K9mxCk/Xg2mde4jHOfGeT0R+DWwjNGJ xxWLTl9IMDg6yOCNQSnVqmANKxaRw2LblA96kgLmuX8S/49ujMJTfgbVz7atvG6V/u+Y Q593dLlOOP4bRu0putf2dz678Kx4b2qB7+z4ceKZWxOoiCX88NgCtxuBNbBewUwGgTMX veZBsSsXonvgc3RrZd2PF9neU5glW9r8dPLAGRdwTnDn+rE/r02aZI5A6zSeE6FG+RkK W8cA== 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=1RQIApMWgceNlG8KnSqLQhkyhGmxHPhIBQ+ZuyL9QRw=; b=FamQVuEYI2uv30sIPC4iVKH2HCrZ2/hWbCBcSFqEGOwpn0NsR0rOw+PrAikwYE1P5m /zNhywqjwsKzZ6vNhj0IErlOq4mYN9z59LfYaP3jaAHee+xDRBb39cQBeYYz40i1Ak9B WmGJUDm/WmKdm+045PKrCBPFQbjmVjsK6M/hB1rIs6Xown/v4u/RFinghloLpFfOcjtk kKw+6N1/AWx92qZI6S6Hbhad0IjiHMVLzHOrovw4B76DwxjzMGEeZd9JWtcyBttgHZMS H4VvUAEEholC3Dund+N83HJdFkrHgZdGrsFC/Qxeypz0jhp8RI4d4ZUzQaDR5Q4nF9po pSOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PxBhIlCx; 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=fail (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 ay11si3493425ejb.331.2020.10.28.09.14.00; Wed, 28 Oct 2020 09:14:23 -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=PxBhIlCx; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1815380AbgJ0RB5 (ORCPT + 99 others); Tue, 27 Oct 2020 13:01:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:43604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1793806AbgJ0PIY (ORCPT ); Tue, 27 Oct 2020 11:08:24 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 CE25C20657; Tue, 27 Oct 2020 15:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811303; bh=wWbs1UGSqdR2FTnQVaRc1tAyM2/+6zbxQcWFKvLvZ1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PxBhIlCx9WH5wnvGDEP67OBl+U8jE6XUD8HLGLoqeyLSG05O9ueoTvagJk4AtMYw9 nGPbxPcnwq+94vnlKHyvZCZjECJFnSPmEkk7JycDpuSTVIQgSA4vrixkxE32r95W3W dPVg5flgHchRQYL/VjrKadG+rFpA49fC58TzybZg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hauke Mehrtens , Lee Jones , Thierry Reding , Sasha Levin Subject: [PATCH 5.8 444/633] pwm: img: Fix null pointer access in probe Date: Tue, 27 Oct 2020 14:53:07 +0100 Message-Id: <20201027135543.549006220@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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: Hauke Mehrtens [ Upstream commit b39c0615d0667b3a6f2f5c4bf99ffadf3b518bb1 ] dev_get_drvdata() is called in img_pwm_runtime_resume() before the driver data is set. When pm_runtime_enabled() returns false in img_pwm_probe() it calls img_pwm_runtime_resume() which results in a null pointer access. This patch fixes the problem by setting the driver data earlier in the img_pwm_probe() function. This crash was seen when booting the Imagination Technologies Creator Ci40 (Marduk) with kernel 5.4 in OpenWrt. Fixes: e690ae526216 ("pwm: img: Add runtime PM") Signed-off-by: Hauke Mehrtens Acked-by: Lee Jones Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/pwm/pwm-img.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c index 599a0f66a3845..a34d95ed70b20 100644 --- a/drivers/pwm/pwm-img.c +++ b/drivers/pwm/pwm-img.c @@ -277,6 +277,8 @@ static int img_pwm_probe(struct platform_device *pdev) return PTR_ERR(pwm->pwm_clk); } + platform_set_drvdata(pdev, pwm); + pm_runtime_set_autosuspend_delay(&pdev->dev, IMG_PWM_PM_TIMEOUT); pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_enable(&pdev->dev); @@ -313,7 +315,6 @@ static int img_pwm_probe(struct platform_device *pdev) goto err_suspend; } - platform_set_drvdata(pdev, pwm); return 0; err_suspend: -- 2.25.1