Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1123759pxx; Tue, 27 Oct 2020 08:47:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGlduxSRyCVYLIDBCU6g3m7p+jKHsGjL6lLg5BICvN9hJM7pbG+wuA8Q9zN4NwWSF7Dx1x X-Received: by 2002:a50:8426:: with SMTP id 35mr2911088edp.156.1603813661386; Tue, 27 Oct 2020 08:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603813661; cv=none; d=google.com; s=arc-20160816; b=nzbB8fuObAcCFS/0e99e37Sjy/lA1a/ThzAbN7xAEuUWC2uncY2UhfbpvUpMNhpPhh t6xOX2S84n/1RE9SsgOk5sv68Cj5e0c4CEfr6FTpYMmd9VmbiqPq6lzpvwYPCMsXV+Dj jBaWhD3Z9InBkpt/vO1ZvhWpbJMBcoEGmoNQf3TMY1ABfgcWyMKAal0nm5wMLz7GkYTq y7F1RPzwHqZzvTQsCYIKJMW/el1DNcXwsVxDcRJw0vkQK3DaPiCXDQQ7bD1BChQEffjJ 567gj65qHReNALgGncPiv13/V9B4yPiEdSf/is/GWQJ45D+KleJ4gjA6OiiKOfcajmxI lZaQ== 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=r4ZP7chYZ+s5aMD3FPhFjRRSWcC82t/DSrHcuQK5nZna8IiQJrwG6soGY48JO53VlO vjTcCwqOc5LHf0VfefuYuvPsWBOFoBRvDkp+6a+6BD4RDht9oTPahHX2psWQIUmTmPFJ DqdWillddTIdgFttYB4Fut7ISl40MONRXIHclphiKCCnpMCJlqndDisxLt7v8n2LA2gm +KhD61k9t5c0et/Lek/gHHX6AxAeu/BnTWAh7DKSdye9CB3GjuFL1rHQO7wdyt4J5+u8 tjfuz7IZs4HlX0nHVAvF//NG8GScDgm5PrXDAsU6TxAZFTOIosf2yHNIpoOQ6Q+0Jqq5 oaeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=05winwhU; 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 c27si1125697edj.467.2020.10.27.08.47.17; Tue, 27 Oct 2020 08:47:41 -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=05winwhU; 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 S1762556AbgJ0OnY (ORCPT + 99 others); Tue, 27 Oct 2020 10:43:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:39786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1749957AbgJ0Okq (ORCPT ); Tue, 27 Oct 2020 10:40:46 -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 1106920773; Tue, 27 Oct 2020 14:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809645; bh=wWbs1UGSqdR2FTnQVaRc1tAyM2/+6zbxQcWFKvLvZ1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=05winwhUjDKbLLqx53nXM+rL59n6vbjPehknegO1GcGto+/wMth6dlEgC+oJop/VQ LuAFT+hpBZu6OoXRdZu7aCQ3Fpexm8XyY+eYyPpiMtMwY88bUG+of9UvlCBu0sfCok 8o/gQin2F++/LQl19l8QOFFp9kYm2MR6t0+Zhj78= 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.4 269/408] pwm: img: Fix null pointer access in probe Date: Tue, 27 Oct 2020 14:53:27 +0100 Message-Id: <20201027135507.529025493@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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