From mboxrd@z Thu Jan 1 00:00:00 1970 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 2055AC25B76 for ; Wed, 5 Jun 2024 08:42:17 +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=uV5YwRmTv3B/QxXq13QE65yMv+l/l1Vc6EnkAlpaWQY=; b=vlIh9VGQVhlsBy wMI7FsZpN4rAnNYqZh45fOPfwx+gHNg5RVaGRfgbPyEBImRlxAvzrqm9r1DZFkiVvW8H3AcMGeWzB Zr62kSHeuyxmus1wy+9JOHJgFpe2Q9ZwgIEq9B5mcItmp2X1iYU6Yoe9TpJkCU7QR/l++cMfQ0zVj lSW2ZYhaDxvtv7fCkOPzGwgz3lBnlDXcB5rF++91IkObl5kwKsK8gl17l6qMDmzbnkyokshQIkWAR BsO2XVh/Jt28iLXrWKHY1KcevbVYIFFaAPco6WTjV9BlsrwAbIlrxeixzWPLdYQGqanc84/NH8Nv1 2ZXjemh37IwYR0Z64hHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEmDc-00000005Gb1-1AQO; Wed, 05 Jun 2024 08:42:04 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sEmDa-00000005GZn-0ES7 for linux-arm-kernel@lists.infradead.org; Wed, 05 Jun 2024 08:42:03 +0000 X-UUID: 76e6d52e231711ef82c84f6416ccf2f3-20240605 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=yJOhU36Sulck3XKLceCGLLYHOWWD2hegzqpiQV7qmlA=; b=LEM1Pm0oEJyaMCjJ9gWbRxQpGI/IbWSizTz15yBrUrOogz4YA3pbl6bVg/LFisE/awRm49ehb3TDVcv/IW/Ec/1wWbf0iTchxSJbMNqdOu76oRgGqfJdQxewdXra0hfQH8Q4TcYHQZl+YtVmDQbdfaza8ZB00I0SMTPPTHpDYnM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.39,REQID:964b78b6-fb63-49c6-9c56-62f506414bff,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:393d96e,CLOUDID:ec713d88-8d4f-477b-89d2-1e3bdbef96d1,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 76e6d52e231711ef82c84f6416ccf2f3-20240605 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 470248988; Wed, 05 Jun 2024 01:41:55 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 5 Jun 2024 16:41:51 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Wed, 5 Jun 2024 16:41:51 +0800 From: Phil Chang To: CC: , , , , , , , , Subject: [PATCH] hrtimer: check hrtimer with a NULL function Date: Wed, 5 Jun 2024 16:41:49 +0800 Message-ID: <20240605084149.6420-1-phil.chang@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--3.213600-8.000000 X-TMASE-MatchedRID: iX1jgSPyW0MyRohotsnq58nlbo5l7mGFIaVkFIrQFhvIvQIyugvKdTcG i0cOVVas3BlBvFCka9vSwA55kcDk3AQmkMsZWj5Btw+xHnsmQjPt/okBLaEo+PGdmr05lx3uh29 kdZ+JxXd6wzwWse0GPMTTRBeQbHHJ4X8HWMSNX7obLGyK+CyynruesBT0pDFRr3/jxaIcqUijxY yRBa/qJcFwgTvxipFa9xS3mVzWUuA152LecOHHIwca30uf/jvRgPl3osVJSN/wVkpD0xi45QwMz A7WoSpZ1xb9AUchuK0SYeEaauBUU2dWz3iro9yhm+i9Sq1gE3ZVDwmeFLwirS9GZyhImPsFdmtR sRmKkASJZPT2ZDPuzPD2QfzMDLjho65UufHcDvg= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.213600-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 62FD71F87D3C8F06B47FFB7EE4A3A63358C9398A4C51ADBED4F0102CDBD008D22000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240605_014202_195812_0540C44C X-CRM114-Status: GOOD ( 10.87 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org simillar with timers, check for timer->function == NULL. If the pointer is NULL, discard the request silently. Signed-off-by: Phil Chang --- kernel/time/hrtimer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 492c14aac642..72d6e7bc9cd9 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1297,9 +1297,13 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, base = lock_hrtimer_base(timer, &flags); + if (!timer->function) + goto out; + if (__hrtimer_start_range_ns(timer, tim, delta_ns, mode, base)) hrtimer_reprogram(timer, true); +out: unlock_hrtimer_base(timer, &flags); } EXPORT_SYMBOL_GPL(hrtimer_start_range_ns); @@ -1667,6 +1671,11 @@ static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base, __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, 0); fn = timer->function; + if (WARN_ON_ONCE(!fn)) { + /* Should never happen. */ + goto out; + } + /* * Clear the 'is relative' flag for the TIME_LOW_RES case. If the * timer is restarted with a period then it becomes an absolute @@ -1710,6 +1719,7 @@ static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base, * hrtimer_active() cannot observe base->running.timer == NULL && * timer->state == INACTIVE. */ +out: raw_write_seqcount_barrier(&base->seq); WARN_ON_ONCE(base->running != timer); -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel