Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3690250pxb; Mon, 24 Jan 2022 15:27:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+yp31TEKf595JmpfbiYu22OdScDeIjZmOg4Z5nGRlBKepDp+amDhc25/qkORu27DHuef4 X-Received: by 2002:a17:902:db0a:b0:14b:59c5:96cf with SMTP id m10-20020a170902db0a00b0014b59c596cfmr5081634plx.126.1643066875736; Mon, 24 Jan 2022 15:27:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643066875; cv=none; d=google.com; s=arc-20160816; b=tERtILWqH9mNy9NZGR4ckmyNoLzSJuGK76PjgLsqhEwG1zEisU886qfEbaYMab2bCV pUfB30WYK+AjKgO+u+N2I9ZAMK0zbEBmxWzkGdZgSheI6pVyu9NTt9iCU/f7lRE2ewZM VeMfgAplECVtj15mYUAwEzfLGmz8udhfNlhTdXvd9MvFKz8GQgxksv4QQAcHjAl+JMCq i3d1tYsCnR7qzubMKlOrlC14lk2tTQmogxAcUe9NcERqXAjHbQ8kFMiNss6SGUIOXgVZ 9nn17VGU9eJ1rW3+4RozyndjmCY03kt2CZ48VBfvnoFvXVo7g3W3+A6ZpWCncKHzzC6e fYfQ== 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=w55nloUx/2pMzRWd/2dWqNdpfopealj91YjWmkEc0os=; b=mZCIlKhj0HzQdVBeUndx7Q+PnTQ3TrOgULzctkpsPx8IrvpOLH3wrPKY5ZxKF2brNz LuUFCvnIcGavIlJecR6jab/UJv28+YFF0aNsoAPaDxDkTmGRjZsU/+d7K6Mb7Jk+sc+D ZT6AjCU4EwNWcit8IvrlvMNDyGyUD/h9RJbcS2FbWfnS0G0TtycP2TxEM/8815jQNwpD nxcpL8LusViGVEgM9XL7+fG4VjOygiFo4vJwqThtyOpaXAGxqDAuddXw2OEYD+M22HVU IwEUFn9fs7UegDkAb0IC+BNVsFWiE02QPL6YtJRRkn2DuUS24DFwLVVLyfC5+7S+RgVQ G5Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mxryHwxW; 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=pass (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 134si15618614pgb.40.2022.01.24.15.27.44; Mon, 24 Jan 2022 15:27:55 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=mxryHwxW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1847954AbiAXXVR (ORCPT + 99 others); Mon, 24 Jan 2022 18:21:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1584545AbiAXWVY (ORCPT ); Mon, 24 Jan 2022 17:21:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDA0DC0424CF; Mon, 24 Jan 2022 12:50:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 732EAB80FA1; Mon, 24 Jan 2022 20:50:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB3E7C340E5; Mon, 24 Jan 2022 20:50:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057407; bh=t36Qf7OqaHp5mhLh63Ejubt/7CRwFd48SoJJMeaqkEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mxryHwxWoHZChzr6ovZ6iOQvaJnOe52Rq8DCM78TKHv7RIBx9SfCPfhebZfNHMpSY KCYxmjHQdoAL+ghyS24hzK6waKWCyOQq0K1RmapDN50WV+wj7dZDBR/11lvXj69wbi XQ6O6rzK7NQL4NWIKpzttbeIT5YVPtP34aBT4Fs8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurence de Bruxelles , Alexandre Belloni Subject: [PATCH 5.15 803/846] rtc: pxa: fix null pointer dereference Date: Mon, 24 Jan 2022 19:45:20 +0100 Message-Id: <20220124184128.642134089@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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: Laurence de Bruxelles commit 34127b3632b21e5c391756e724b1198eb9917981 upstream. With the latest stable kernel versions the rtc on the PXA based Zaurus does not work, when booting I see the following kernel messages: pxa-rtc pxa-rtc: failed to find rtc clock source pxa-rtc pxa-rtc: Unable to init SA1100 RTC sub-device pxa-rtc: probe of pxa-rtc failed with error -2 hctosys: unable to open rtc device (rtc0) I think this is because commit f2997775b111 ("rtc: sa1100: fix possible race condition") moved the allocation of the rtc_device struct out of sa1100_rtc_init and into sa1100_rtc_probe. This means that pxa_rtc_probe also needs to do allocation for the rtc_device struct, otherwise sa1100_rtc_init will try to dereference a null pointer. This patch adds that allocation by copying how sa1100_rtc_probe in drivers/rtc/rtc-sa1100.c does it; after the IRQs are set up a managed rtc_device is allocated. I've tested this patch with `qemu-system-arm -machine akita` and with a real Zaurus SL-C1000 applied to 4.19, 5.4, and 5.10. Signed-off-by: Laurence de Bruxelles Fixes: f2997775b111 ("rtc: sa1100: fix possible race condition") Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220101154149.12026-1-lfdebrux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-pxa.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c @@ -330,6 +330,10 @@ static int __init pxa_rtc_probe(struct p if (sa1100_rtc->irq_alarm < 0) return -ENXIO; + sa1100_rtc->rtc = devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(sa1100_rtc->rtc)) + return PTR_ERR(sa1100_rtc->rtc); + pxa_rtc->base = devm_ioremap(dev, pxa_rtc->ress->start, resource_size(pxa_rtc->ress)); if (!pxa_rtc->base) {