Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp258915lqp; Mon, 10 Jun 2024 03:18:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVapgd1LH4LHPp3olNpasiM7kGhz7bFd05KmmfrylbDdiGaYpbmUi1KyPIZcXGqYmaAwLGXJtmzFYfuVSdyFLHsLsyb8wqHU49muH6dZQ== X-Google-Smtp-Source: AGHT+IFVvs3j60Fe4Oepbh203VhZLR9DDStHhdzyslT5fiKRFobZQGOV4CkbRCq9vn3imw1Kwv3k X-Received: by 2002:a05:6359:2c45:b0:19f:2d30:8e02 with SMTP id e5c5f4694b2df-19f2d309cbdmr601762955d.31.1718014683415; Mon, 10 Jun 2024 03:18:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718014683; cv=pass; d=google.com; s=arc-20160816; b=ZWYU7zlOho6W3abdHjjl37BseN6TIgPkI3+DKpLAfmtDZVAy7hrxjQkw0U0lijaSpR G3xjm/Hr25SHr2B5f+/u9S8A2RWD8rXkeQEj9u1a62No2PbFMLCpzAHB1UQdszC+Upvl dll33zLCaP0eIFuKqL06/DK18gv3M1G2S293CYGa53eT77m39Xbx/0VkUkhZOmcvPhMD utGEI72q7/H+gznggBm5GWowDooheCzQq7SVUjxheuoXgnuRHrVw98H8jlk0BSMlqKV1 4hPRGa+98Gp81wsBfFNIKDDB6YGEqFnVs9UqaAzr/8sj1y/dLFyAsfPkiKqzOSmXchSs cx9Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=niYe53zUpXvYd4fxzEQMt55McnLdwhYGnjG+n4GezzE=; fh=LIcSsH5MUp5WEGEVzBJLCceHSZSKi0ivCE2rUoawWYE=; b=EzHkSMa4ZSThkjLT3Wfh7RfGIGKQUtyyua+EvmRWPqYNF5IAEHcBbNmEUPnDNjUl/3 eoEjHy+EV8FbLA13SRR806MYNrNDnca+ViCHaWtAbXI7Hm8gPWHjZE/t4S29nhboO04a X7tTzjfguW6rdX5bsHg90w7V2VQR8Te6yrFifoOlYh2bW8Lw+01KvgutlACjgkDE9mVX mm3Egz5KgzYiy91wPiWEIxiT4A9TssjjPJsc67RbaniKsODkQy8rU0pEQSWutZbRJfin zmYO++obghoJpRdI28UNNobdAXUD+KWavAF4+sNZ2iFT+WRufVt+e3s+cJYyCR3ZlBIk l6Fg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=M4gvTaGs; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-207962-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207962-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de262c0417si7394994a12.262.2024.06.10.03.18.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 03:18:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207962-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=M4gvTaGs; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-207962-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207962-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 09945B23CBB for ; Mon, 10 Jun 2024 09:47:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5C59757FD; Mon, 10 Jun 2024 09:47:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="M4gvTaGs"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cnvu1XqA" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86D5942AA1 for ; Mon, 10 Jun 2024 09:47:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718012865; cv=none; b=QxpiI3T6HazqSn5syY1NvVptHOmfIY3l1iesEJGPNWGAjaHV2IUolSO/gdXOEcDgKD8j4JMYfOXAW9vWy+1cxVph7+EC5V4oiE2nwMiFJT1IHyPrSh3pvy23oVa1Nl1ak6QmEySboRZV1ZLoopYP68vXZznkffy5IEftatV8ta4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718012865; c=relaxed/simple; bh=ARGhxvS/s5Dj2XsNG+1mlK6zCS2uhIKNCt8LkqeooFU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=pO1BdDP0eyptWTI2jr46s+KgM1tJm9ptTi2hNMtQlv7PcXXy0zou2+uCLgQc6l79PKlTB6m3sHAylFqLWYXPW73lV2LjHXStz5L1jbprIBRJb2DCMPZZlNwnABN4osFzMRKkF3zz5ndYuz/+Z2CxkW4e0jTbPn/BHNYjD7ZjL0U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=M4gvTaGs; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cnvu1XqA; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718012861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=niYe53zUpXvYd4fxzEQMt55McnLdwhYGnjG+n4GezzE=; b=M4gvTaGsbM16AqQsriJORCFrrntzmFgB8Is7s6pQ78LdU2HWRJRnFgJxndSudK0nAsmMMA eC3OH0V+NN2ciJDyT15zM0nQ0kG+03ziVyZQd/wORTSL78pHfA6TvqEkMNE+ES1Zi2OPWp 6s2ntQmR6fODt9phl6r9h1dL3Mx00bzYuPI2UF6jal0h0/vUt+wDfVtqr0VwoMFXg6MvKF I9QmXH/kQFmD3TrrLJa7Uj80PV3D+MnrPUz9SoITH9cDOIBfgPu5GOXz7ugt6jH5Qn+nMj 7vFP2a5m0ducqlIANeVRtoJARItHm1lyABCRE6tjX7uJzJg2nJxowA7nukiI6g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718012861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=niYe53zUpXvYd4fxzEQMt55McnLdwhYGnjG+n4GezzE=; b=cnvu1XqAXICWboO3c93v5ayawLJHbfSxDolW8t5qb7iy4hCL0hPGYDFolliObaqLRClvQR xBnTmrTVpPL/VPBA== To: Phil Chang Cc: alix.wu@mediatek.com, angelogioacchino.delregno@collabora.com, frederic@kernel.org, jy.ho@mediatek.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, matthias.bgg@gmail.com, phil.chang@mediatek.com, tglx@linutronix.de Subject: Re: [PATCH v2] hrtimer: check hrtimer with a NULL function In-Reply-To: <20240607022614.22902-1-phil.chang@mediatek.com> References: <877cf2i56q.fsf@somnus> <20240607022614.22902-1-phil.chang@mediatek.com> Date: Mon, 10 Jun 2024 11:47:40 +0200 Message-ID: <87bk496seb.fsf@somnus> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Phil Chang writes: > Since hrtimers do not allow a NULL function to be passed, > to prevent a kernel crash, return before adding the timer to a queue. You could point out in the commit message, where the kernel would crash when using a hrtimer with a NULL pointer as function pointer. And it shouldn't be a problem to use more than a single sentence for a commit message :) > Signed-off-by: Phil Chang > --- > kernel/time/hrtimer.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c > index 492c14aac642..d32c1afe59b3 100644 > --- a/kernel/time/hrtimer.c > +++ b/kernel/time/hrtimer.c > @@ -1285,6 +1285,9 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, > struct hrtimer_clock_base *base; > unsigned long flags; > > + if (WARN_ON(!timer->function)) > + return; > + Please use a WARN_ON_ONCE() (as documented in Documentation/process/coding-style.rst) > /* > * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft > * match on CONFIG_PREEMPT_RT = n. With PREEMPT_RT check the hard Thanks, Anna-Maria