Skip to contentSkip to conversation

Device list sort function bug

Powertop Jan-Simon Möller <dl9pf at gmx.de> 1 participant 1 message Jul 11, 2012

lore
Share & tools
lore

Jan-Simon Möller <dl9pf at gmx.de>

Acked-by Jan-Simon Moeller
#0 lore raw

Am Mittwoch, 11. Juli 2012, 09:33:42 schrieb Sergey Senozhatsky:

Quoted 11 lines · Igor Zhbanov
Quoted 9 lines

Sometimes PowerTOP dies with a Segmentation Fault while generating the report. Little investigation shown that it dies while sorting the device list. The problem is that comparison function devlist_sort is incorrect.

The function should return true if first argument "preceeds" second. But when strcmp() is used, it can return -1, 0 and 1. So both -1 and 1 values are silently converted to true, which is wrong. It confuses the sort() function and it crosses boundary of array.

Quoted 5 lines

Jan, could you please test this one?

Thanks in advance,

	-ss

Confirmed. Fixes the crash & works here.

Acked-by Jan-Simon Moeller <dl9pf(a)gmx.de>