Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1357467rwi; Thu, 27 Oct 2022 14:53:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7QH53bGpNICdVYJBmZpJCKN9ZrrCm/XfL6uVvY5myUwlMsCZrIUAW9LmYrZtPODY6f7svh X-Received: by 2002:a17:906:cc52:b0:78d:d477:5b7f with SMTP id mm18-20020a170906cc5200b0078dd4775b7fmr43411563ejb.558.1666907610509; Thu, 27 Oct 2022 14:53:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666907610; cv=none; d=google.com; s=arc-20160816; b=GZb723tVAmZPNUVgYzhd0SHA3egaf5aWl145Uj/TmiKFBR9Mzkh4r3xI2HiCB/8zMw zketc4zKW6tR+uw/93LX+lh8ErsGA2DDCqlyeZGRCqTEjNRg+t44C5jdHy/g7c9jAt2O svVvKfmKySbbNtr1vXqrhweiDfbYu2yFYsosISVXoRw8YCKWPBob03LSSJ6docUiH1jP KFR4NO/PINBW43rptO3rQh53+30Qa/SUC7575J2eq+AS3SZ18ZC4ZRudwUZ3bpC6SBWM 3RuA4QfI4Kjzw/wv63/cexmG4IUsuD61fTEIrQ5DNi61dXHh5xiqZoC8k62+UkjAfMVD NUZw== 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 :feedback-id:message-id:subject:from:to:dkim-signature:date; bh=qOqRsISaPy8WRtmUNjqUH5CrgfQe9GLu6VNSH2AUc/s=; b=nQf+HgnrDESeY9978K5QaPl94ICvDKLcIS7NLjMovd0foacMiVAXoqLsj4vl/3VhHm thMomFbaFRwWMvhK9arAbrREjofqsmuIm28nlMPX5udBX9D6wAA9q7EKOR51DKwAP8f6 a5F31hYcVytGM2SrLSX8JSBc9iv1x15GnU4Y1+Pm86x+O/evNSMd4FqG/pjNLd57djNj v9o0qTP3yHaywqDrZKHH2DO98ECstFx+NQkpvUGVUOZeRQGsmEhRev+c3GFzlW0Xl7ck lVhmZLoz7r2qHGJ/6G/MKkbN27YzkD22YH/NGVhuUKCasfFJpAlNeMtKVpoj2rLtetDn mouQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b="FUFE/3cT"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kx10-20020a170907774a00b00783e7d72fc0si632519ejc.272.2022.10.27.14.53.05; Thu, 27 Oct 2022 14:53:30 -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=@protonmail.com header.s=protonmail3 header.b="FUFE/3cT"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236336AbiJ0VhW (ORCPT + 99 others); Thu, 27 Oct 2022 17:37:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235481AbiJ0VhU (ORCPT ); Thu, 27 Oct 2022 17:37:20 -0400 Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB86972B44 for ; Thu, 27 Oct 2022 14:37:19 -0700 (PDT) Date: Thu, 27 Oct 2022 21:37:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1666906638; x=1667165838; bh=qOqRsISaPy8WRtmUNjqUH5CrgfQe9GLu6VNSH2AUc/s=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=FUFE/3cT8xKN0tQFmfifVFz88b0tVnn05nOWRJz6RMFuyIVoScOMtmZcjMgtziie4 MxG9YxlRRA1UA+hY94Ssevq51eqIh46gUNcIsadtfzTYTsZVlHpC7fLesKciU6Zt2+ xelEeKGl8MdkBdbMX89Cy5JKxYobSOmElEEIlc/nwZZS87l+SX1csliEIg+0w1GaKL J/1bfTYwGQMKqorT/0kqwHcIrELVnln3hr54KNYGaKfGqAGOfjWnUUtGA+5GRn+Wna wVDAEsyeFhjQgXgEVvxCh3jGB27z5s4QceGInX2XjKV0RTHO5sWb+OgCtp2YY6UGkZ ZNYW9gCkxy3YQ== To: linux-kernel@vger.kernel.org, Thomas Gleixner From: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v1] timerqueue: use rb_entry_safe() in timerqueue_getnext() Message-ID: <20221027212506.3745164-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_PASS, SPF_PASS 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 When `timerqueue_getnext()` is called on an empty timerqueue the returned rb_node pointer will be NULL. Using `rb_entry()` on a potentially NULL pointer will only - coincidentally - work if the offset of the rb_node member is 0. This is currently the case for `timerqueue_node`, but should this ever change, `timerqueue_getnext()` will no longer work correctly on empty timerqueues. To avoid this, switch to using `rb_entry_safe()`. Signed-off-by: Barnab=C3=A1s P=C5=91cze --- include/linux/timerqueue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/timerqueue.h b/include/linux/timerqueue.h index 93884086f392..adc80e29168e 100644 --- a/include/linux/timerqueue.h +++ b/include/linux/timerqueue.h @@ -35,7 +35,7 @@ struct timerqueue_node *timerqueue_getnext(struct timerqu= eue_head *head) { =09struct rb_node *leftmost =3D rb_first_cached(&head->rb_root); -=09return rb_entry(leftmost, struct timerqueue_node, node); +=09return rb_entry_safe(leftmost, struct timerqueue_node, node); } static inline void timerqueue_init(struct timerqueue_node *node) -- 2.38.1