From patchwork Fri Feb 25 16:19:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 12760532 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42C2FC433EF for ; Fri, 25 Feb 2022 16:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4719laCbdhj6hpdO+MWFqig6sbFhRtRu/YgjUsN1D80=; b=q1KQga00Y6pZI9 3Rzp945ZBVMLREJ0S7ZkaRNMExqk9G8S9MHm9OFzQ5oS7Pu3PeifQuuRaYo9GLWcdwg4cRQEEhaig 9qHIUS1jNqtdYNixHOOyszJc+xJk8MyTF9H5xhUXpbl9muuAB3Fa/w7w5fxMet4qXgNbpBporNV5E 5ZBiIor5LwOq5FJuS3Kei38y4COrvOpSAaCbP+mxBZc9FSzNQluEqsz2oYDkLMVtEETuv55r9swEI ceOZUybSVXEOX5PoP3+Rsz+XOUQOzjajjmuMfGqLkW7ox+asu09qXpFE8qp6U1KQueYlazF9aosuR 6Kj+AtMeHyvaq6Ux987g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNdJw-005sSC-KB; Fri, 25 Feb 2022 16:19:52 +0000 Received: from alexa-out-sd-02.qualcomm.com ([199.106.114.39]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNdJs-005sQ6-H4 for linux-arm-kernel@lists.infradead.org; Fri, 25 Feb 2022 16:19:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1645805988; x=1677341988; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=jV1/rxSD+P2pkzp3I06vMJiO2j7BJNM6TvzL+/6SkCM=; b=MY3GQtTD3EYqUs1BgFBod2UkVAMHwKJeM+w3k0frrqrdO7gHNaSNikj7 VWbJhDBl9ZfpB1Cn3xdMdXuzwDUspAhs2xdSoWlzkTijDXZg+ilS9DLQ/ Jf82YdEBCOQNmxFhY/qq0F+6acAN06/RrVJ/T+p2CcCgRIQIPY6VwGiuf k=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-02.qualcomm.com with ESMTP; 25 Feb 2022 08:19:45 -0800 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2022 08:19:45 -0800 Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Fri, 25 Feb 2022 08:19:44 -0800 From: Elliot Berman To: Linus Walleij , Alessandro Zummo , Alexandre Belloni CC: Ali Pouladi , , , , Carl van Schaik , , Elliot Berman Subject: [PATCH] rtc: pl031: fix rtc features null pointer dereference Date: Fri, 25 Feb 2022 08:19:24 -0800 Message-ID: <20220225161924.274141-1-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nasanex01b.na.qualcomm.com (10.46.141.250) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220225_081948_622136_ACB3C0D3 X-CRM114-Status: GOOD ( 12.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ali Pouladi When there is no interrupt line, rtc alarm feature is disabled. The clearing of the alarm feature bit was being done prior to allocations of ldata->rtc device, resulting in a null pointer dereference. Clear RTC_FEATURE_ALARM after the rtc device is allocated. Fixes: d9b0dd54a194 ("rtc: pl031: use RTC_FEATURE_ALARM") Cc: stable@vger.kernel.org Signed-off-by: Ali Pouladi Signed-off-by: Elliot Berman --- drivers/rtc/rtc-pl031.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index e38ee8848385..bad6a5d9c683 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c @@ -350,9 +350,6 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) } } - if (!adev->irq[0]) - clear_bit(RTC_FEATURE_ALARM, ldata->rtc->features); - device_init_wakeup(&adev->dev, true); ldata->rtc = devm_rtc_allocate_device(&adev->dev); if (IS_ERR(ldata->rtc)) { @@ -360,6 +357,9 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) goto out; } + if (!adev->irq[0]) + clear_bit(RTC_FEATURE_ALARM, ldata->rtc->features); + ldata->rtc->ops = ops; ldata->rtc->range_min = vendor->range_min; ldata->rtc->range_max = vendor->range_max;