The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Todd Brandt <todd.e.brandt@linux.intel.com>
To: Gongwei Li <13875017792@163.com>,
	"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Gongwei Li <ligongwei@kylinos.cn>
Subject: Re: [PATCH] PM: tools: fix ValueError when parsing incomplete device properties
Date: Thu, 30 Apr 2026 10:26:39 -0700	[thread overview]
Message-ID: <31cae88810593e091de28809a220ba31a67ee0bd.camel@linux.intel.com> (raw)
In-Reply-To: <20260424071208.3610628-1-13875017792@163.com>

On Fri, 2026-04-24 at 15:12 +0800, Gongwei Li wrote:
> From: Gongwei Li <ligongwei@kylinos.cn>
> 
> When parsing device properties from ftrace data, the devprops()
> function
> assumes that each line has at least three fields and that the third
> field
> (f[2]) always contains a valid integer. However, due to incomplete or
> corrupted ftrace logs, f[2] may be missing, empty, or non-existent.
> 
> This can lead to the following error:
> 
>     Traceback (most recent call last):
>       File "../sleepgraph.py", line 7142, in <module>
>         stamp = rerunTest(sysvals.outdir)
>       File "../sleepgraph.py", line 6255, in rerunTest
>         testruns, stamp = processData()
>       File "../sleepgraph.py", line 6181, in processData
>         testruns, error = parseTraceLog(live)
>       File "../sleepgraph.py", line 3470, in parseTraceLog
>         tp, tf = loadTraceLog()
>       File "../sleepgraph.py", line 3398, in loadTraceLog
>         if tp.stampInfo(line, sysvals):
>       File "../sleepgraph.py", line 3073, in stampInfo
>         self.parsePlatformInfo(line, sv)
>       File "../sleepgraph.py", line 3177, in parsePlatformInfo
>         sv.devprops = self.devprops(sv.b64unzip(info))
>       File "../sleepgraph.py", line 3158, in devprops
>         if int(f[2]):
>     ValueError: invalid literal for int() with base 10: ''
> 
> To prevent this crash, add proper validation before accessing.
> 
> Signed-off-by: Gongwei Li <ligongwei@kylinos.cn>
> ---
>  tools/power/pm-graph/sleepgraph.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/power/pm-graph/sleepgraph.py b/tools/power/pm-
> graph/sleepgraph.py
> index 1555b51a7d55..f6d172254829 100755
> --- a/tools/power/pm-graph/sleepgraph.py
> +++ b/tools/power/pm-graph/sleepgraph.py
> @@ -3155,7 +3155,7 @@ class TestProps:
>                         dev = f[0]
>                         props[dev] = DevProps()
>                         props[dev].altname = f[1]
> -                       if int(f[2]):
> +                       if len(f) > 2 and f[2] and int(f[2]):
>                                 props[dev].isasync = True
>                         else:
>                                 props[dev].isasync = False

This looks good, thanks for the catch! Raphael can you apply this?

Signed-off-by: Todd Brandt <todd.e.brandt@intel.com>


  reply	other threads:[~2026-04-30 17:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24  7:12 [PATCH] PM: tools: fix ValueError when parsing incomplete device properties Gongwei Li
2026-04-30 17:26 ` Todd Brandt [this message]
2026-04-30 17:38 ` Todd Brandt
2026-04-30 18:35   ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31cae88810593e091de28809a220ba31a67ee0bd.camel@linux.intel.com \
    --to=todd.e.brandt@linux.intel.com \
    --cc=13875017792@163.com \
    --cc=ligongwei@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox