]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PM: tools: pm-graph: fix ValueError when parsing incomplete device properties
authorGongwei Li <ligongwei@kylinos.cn>
Fri, 24 Apr 2026 07:12:08 +0000 (15:12 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 30 Apr 2026 18:33:23 +0000 (20:33 +0200)
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>
Acked-by: Todd Brandt <todd.e.brandt@intel.com>
[ rjw: Subject tweak ]
Link: https://patch.msgid.link/20260424071208.3610628-1-13875017792@163.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
tools/power/pm-graph/sleepgraph.py

index 1555b51a7d556102eeb1c00350279b68dc994c34..f6d172254829b2f788a59dadd95dd807b4fe4027 100755 (executable)
@@ -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