OSDN Git Service

powercap/intel_rapl: fix and tidy up error handling
authorJacob Pan <jacob.jun.pan@linux.intel.com>
Mon, 28 Nov 2016 21:53:11 +0000 (13:53 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jan 2017 19:18:07 +0000 (20:18 +0100)
commitaa3ee06a2ae2fe7b7b65fc9a82d52b96f99ab1d6
treec8da44bd7659bd863ba4185b66c7cfbf7d7eb404
parentf53cfb081f000bb07f838515bf090a9d7d9047c6
powercap/intel_rapl: fix and tidy up error handling

commit cb43f81b8489dcb87555e16c17453f0a9fa690f2 upstream.

Commit e1399ba20eee ("powercap / RAPL: handle missing MSRs") added
contraint_to_pl() function to return index into an array. But it
can potentially return -EINVAL if powercap layer sends an out of
range constraint ID. This patch adds sanity check.

Unnecessary RAPL domain pointer check is removed since it must be
initialized before calling rapl_unit_xlate().

Fixes: e1399ba20eee ("powercap / RAPL: handle missing MSRs")
Reported-by: Odzioba, Lukasz <lukasz.odzioba@intel.com>
Reported-by: Koss, Marcin <marcin.koss@intel.com>
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/powercap/intel_rapl.c