Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp342317pxm; Fri, 25 Feb 2022 09:02:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUIog8TocUsJOhLkPly6DQBbMGzQaD8zaolSl9Gwq6x32E96R/LWwedcPr5CNVC3o8l1/X X-Received: by 2002:a17:902:6b04:b0:14f:2cc0:fa98 with SMTP id o4-20020a1709026b0400b0014f2cc0fa98mr8333768plk.44.1645808526281; Fri, 25 Feb 2022 09:02:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645808526; cv=none; d=google.com; s=arc-20160816; b=Lc5WScdSk49CEKtfz2sc0Wf6A1rSJ7zyTQWGmwzXg8jW7ymlw9jkn/rqELBmW5ztGY 5nVw+Ik9TFgYfWzIsrYwPTFgWo3uhRS5aS35SUVEJwrgWn6+Drtp1y/45IVXmQaXnkQV h35dRhl8jPWhXWeN7RDwD6YeElg5mv1zpld6o6VovjuQJP4WXDfm2Cfb6eMbyX59Z44j ijVyrcodDpwsuLNhwdfN503tZK5RdtpII+cxTrAOdbybwqZnnOTz/KNbII79KIQcGJpW 8NnPk/CoqFCU8GB2v/oWmj9lcW6vKbQiEH8kilUeBmug7iDC6qU64IhuL+AQPeaoUex7 t/mA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=jV1/rxSD+P2pkzp3I06vMJiO2j7BJNM6TvzL+/6SkCM=; b=X9QblQCnz9aQv2Pdc6AqN1JyjO5mBygMC3kmL+sSiv3NjpqdM8tnSsGaeZX0IXFRFE 5BTDttgu1FfOI7/CNZq3eGA88NwODzETQQX3aqtiuV87wGOsDnwuzSaKuH7zw5jGcny+ ykXxrZL6aI8P4JjbZI6kAl6Dp7WlIK2MYkhXQkCjrIBzmcTCrAyPYCneoqSvGqfEVrB+ uLkdCcbuG3e4Oblv/xUtU0xaFJI76PK/XUBjhKnWw+dTDIIQA7kReQa6SZG3Q/ooCd3W AmLEguJ/vAV/liPb0zD1R1w7J/v5M7yE+7OYIkaGpZlaWhYHuRQMlSd8MPKWAe4xjx6r Fbew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=sBRXMRfS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a7-20020a170902710700b0014fc1558b77si2075321pll.189.2022.02.25.09.01.48; Fri, 25 Feb 2022 09:02:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=sBRXMRfS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242854AbiBYQU1 (ORCPT + 99 others); Fri, 25 Feb 2022 11:20:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242856AbiBYQUS (ORCPT ); Fri, 25 Feb 2022 11:20:18 -0500 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FAF4532E5; Fri, 25 Feb 2022 08:19:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1645805986; x=1677341986; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=jV1/rxSD+P2pkzp3I06vMJiO2j7BJNM6TvzL+/6SkCM=; b=sBRXMRfSm7VCcv770ZYqVKITUqQ8lTT1YizF/Cj22XXwqUGT7pp+fbJy NwTILF8ToWdFG4vWQIfn0FMHFCNkhxKpHiW1MPnsXLRboGDg4fbDlLXaW +A2ttPEjIprnwunlsgOO+2C3VGpvjgZoxQbeh6yQ4833xuntZUEoQzY7m g=; 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; -- 2.25.1