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 X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03427C4363D for ; Tue, 22 Sep 2020 14:39:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B674B2395C for ; Tue, 22 Sep 2020 14:39:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726694AbgIVOjh (ORCPT ); Tue, 22 Sep 2020 10:39:37 -0400 Received: from thoth.sbs.de ([192.35.17.2]:49103 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726507AbgIVOjh (ORCPT ); Tue, 22 Sep 2020 10:39:37 -0400 X-Greylist: delayed 445 seconds by postgrey-1.27 at vger.kernel.org; Tue, 22 Sep 2020 10:39:36 EDT Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id 08MEW4xx001606 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Sep 2020 16:32:04 +0200 Received: from [139.22.130.132] ([139.22.130.132]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 08MEW2GL031527; Tue, 22 Sep 2020 16:32:03 +0200 Subject: Re: [PATCH] scripts/gdb: fix list_for_each To: George Prekas , linux-kernel@vger.kernel.org Cc: Kieran Bingham References: <3b382958-9f1d-a3d2-a239-09ba084227e6@amazon.com> From: Jan Kiszka Message-ID: <2516a051-306f-670b-1f9e-d46fc577c7f8@siemens.com> Date: Tue, 22 Sep 2020 16:32:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <3b382958-9f1d-a3d2-a239-09ba084227e6@amazon.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22.09.20 16:28, George Prekas wrote: > If the next pointer is NULL, list_for_each gets stuck in an infinite > loop. > > Signed-off-by: George Prekas > --- >  scripts/gdb/linux/lists.py | 2 ++ >  1 file changed, 2 insertions(+) > > diff --git a/scripts/gdb/linux/lists.py b/scripts/gdb/linux/lists.py > index c487ddf09d38..424a91c1aa8b 100644 > --- a/scripts/gdb/linux/lists.py > +++ b/scripts/gdb/linux/lists.py > @@ -27,6 +27,8 @@ def list_for_each(head): >          raise TypeError("Must be struct list_head not {}" >                             .format(head.type)) > > +    if head['next'] == 0: > +        return >      node = head['next'].dereference() >      while node.address != head.address: >          yield node.address Obviously, infinite loops are bad and should be avoided. But NULL is bug, isn't it? Shouldn't we report such a corruption? Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux