Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp667127pxb; Tue, 5 Apr 2022 18:00:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK1XQBOOv1ZZGH3db9uZ4no93GENBL1z1lN2J3eLL0NfN1FP4ROrBwys9FyFps1hT5Ewtk X-Received: by 2002:a17:907:7ba6:b0:6df:ee7d:10f2 with SMTP id ne38-20020a1709077ba600b006dfee7d10f2mr6098420ejc.98.1649206823506; Tue, 05 Apr 2022 18:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649206823; cv=none; d=google.com; s=arc-20160816; b=RsxvGZpuBMpphmeGmYGlcLVzHHelU8KOzHJUOAttn4eVe5lnM+WKeecVlgNxfYzfRB MZyfGMZNkFdA7nMhr/aXcakub3PnE4IiySMHK6nB+kvC5oz6fpNaUN4GGx77yofFZWFl 6dt7inmQtEJpjZDFOUmJ6TBZbvk0lZ/m2FwgR4AH6GI2rPVzwzldR/FaQ9iWUBdKtqEO h22OLISPibkGex2/7y2/9Z+pOq7/F+EP+KsOMu7z/Mx1Lx/2OBbRrr3SBZUdfxgU6LzU Quxdrw1cp5zp1r9QpKN+AvjrhzXZ6h4+lRddtCYor3i6wikvr6/TtvoIMxigi4Fpef8I HIEw== 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=84OS9I1gz0s/8cQUOcyerpFXdvk+qpU4a1fAlQwfyu8=; b=r6U5IRj0L0R2v77eIp9qaQN2oYrOqB2U8Vg9T4qS/dVJkoWyrRUAV7xobVRMnJb43u iTq9jw8/ZviKHflQ75HBli9n9YtQ0mvrKtba7JISr7grSl9YOnxDYo62OoSUzyX+Ihda wWM96ikKcM5zHJeFZzohiQKU8Okpws6ig2fSkDBxqvieqAvwoB9CHTDrkYFyC/hIk2nE XWFmDXs3I9Re6YrqtQ7gXKteHBIZH3r9TGjw4augczny4M5OHd9oafVPWk/Hft50Sivf m4Qnscd0dXNFp7T9O0BZ+tGCSz2Iq1uC1RcaTe5tc9gjgv2UqPebDDDl/A9gzynmDdjq VMAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HbGliJVy; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i14-20020a50e14e000000b0041978615fbfsi10772218edl.379.2022.04.05.17.59.56; Tue, 05 Apr 2022 18:00:23 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=HbGliJVy; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232526AbiDEHyv (ORCPT + 99 others); Tue, 5 Apr 2022 03:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233537AbiDEHr4 (ORCPT ); Tue, 5 Apr 2022 03:47:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D79DA9157F; Tue, 5 Apr 2022 00:45:03 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 75D24616BF; Tue, 5 Apr 2022 07:45:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F9A5C3410F; Tue, 5 Apr 2022 07:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144702; bh=fHq6yezaEyDiwaMdcaDnIeQNeAFcl0kVKFCgE+Qc/VU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HbGliJVy/kl3SLR/mq0y0GJB2oS4MwN0ZWElHtbAKz0Vg/ezAsERI+b47RqK481O9 wpO77pq+J/sfLQwHJAGyg/KyRXWeAj6gUCXzjvbTnNovHTrn7/Pd3ZLiWr3TWxDIap cJMMFbubFzjsjw2sHYHjcROgOwDevZjYjo2WOCBk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ali Pouladi , Elliot Berman , Alexandre Belloni Subject: [PATCH 5.17 0101/1126] rtc: pl031: fix rtc features null pointer dereference Date: Tue, 5 Apr 2022 09:14:08 +0200 Message-Id: <20220405070410.533878006@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 commit ea6af39f3da50c86367a71eb3cc674ade3ed244c upstream. 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 Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20220225161924.274141-1-quic_eberman@quicinc.com Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-pl031.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c @@ -350,9 +350,6 @@ static int pl031_probe(struct amba_devic } } - 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_devic 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;