Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3987097pxk; Tue, 22 Sep 2020 07:43:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZHN3YoKS4BSP8tAer5k5wvvNeh3lRqwQE8EDoNsaAEMucu8zexwCbvQ1MIwGkLQY/i24r X-Received: by 2002:a50:d987:: with SMTP id w7mr4270439edj.113.1600785781442; Tue, 22 Sep 2020 07:43:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600785781; cv=none; d=google.com; s=arc-20160816; b=DspmDazXqYhaESJ9MZcn9d5XUuf8w9gZP+ydR/p8fmsfMlRvFvZxPCSGZUZ8lerqGC W5+WkgBVPkJilvliVkyOzt/WCCet9HYtGToiF4U53K/dZl8ahjCMbpF+pkk5rUz3b8hz BC6nF5p74hfXMcJbHJgJF36iZ0UtEzuo5/KN58w4wsTCNGkeDX10ujMGgtyUC/vJvZV4 d66Mezdg7PjjuscHRSK8tR4vZMly9OrE2BO8S798DqSKk7P48ALnKLjNef5r3CKXZYRg EeudzUkw6K655a9P7BW+7J5gxcCeNd+NMMHVOeZlAOTOd/5RDH+fgCFfEAjb9K4Md6r6 oGwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=qMrgWimf2vSCUYkTd+8IRDfm+vmCieF4LtE0IkZcIE0=; b=W1DEqzIQGupvI6UmvVuG+ZGgRCdPjJuYPQ2YmLcfU4EHDzZ1RCFdBDBW3zoT2IQjU9 SDv5oprbj1d6DF21hPuqdW3Os/4vHTvXfrGWz56h1XWWFAt1W4wp8JF34d2IEAFzR7sA G5hQj4Quzxt26gJVRe4ix8bonH8LXbCcBZFlMi2Mk8t5q/zeeCqztoVcSn94HJRTwbEh P37olXMOKACogBKzOHL2rbHD4SvaDtyC2Ul0WKxBQvVd+jWUHcpj0a81gX4u8pmkg6rc 0Ndi3g2pna6gPRg/4SUAm2pKPqp31/l9joJo3r/HyOoxShwIk7I30MNId/JcS4TdX4xT rlgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ld12si10797120ejb.329.2020.09.22.07.42.38; Tue, 22 Sep 2020 07:43:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726666AbgIVOjh (ORCPT + 99 others); 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