Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755367AbdCaOTd (ORCPT ); Fri, 31 Mar 2017 10:19:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:52459 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754931AbdCaOTb (ORCPT ); Fri, 31 Mar 2017 10:19:31 -0400 Subject: Re: [PATCH 1/2] xen: correct error handling in xen-acpi-processor To: Boris Ostrovsky , linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org References: <20170331111948.17539-1-jgross@suse.com> <20170331111948.17539-2-jgross@suse.com> <56430503-ab15-4ff1-9432-f8c23e8981eb@oracle.com> Cc: konrad.wilk@oracle.com, stable@vger.kernel.org From: Juergen Gross Message-ID: <5ca1a49b-da31-d1cc-46e3-6ff92d9f0833@suse.com> Date: Fri, 31 Mar 2017 16:19:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <56430503-ab15-4ff1-9432-f8c23e8981eb@oracle.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1534 Lines: 51 On 31/03/17 16:10, Boris Ostrovsky wrote: > On 03/31/2017 07:19 AM, Juergen Gross wrote: >> Error handling in upload_pm_data() is rather questionable: possible >> errno values from called functions are or'ed together resulting in >> strange return values: -EINVAL and -ENOMEM would e.g. result in >> returning -EXDEV. > > And it doesn't matter anyway since noone checks return value. (not that > OR-ing errors makes much sense) Ha, you are right! So I can just fold the patches into one and turn some more functions into retuning void. Juergen > >> >> Fix this by bailing out early after the first error. > > I am not sure about this: why should we not try to load P states if C > states failed to load? > > -boris > >> >> Cc: stable@vger.kernel.org >> Signed-off-by: Juergen Gross >> --- >> drivers/xen/xen-acpi-processor.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c >> index 23e391d..3659ed3 100644 >> --- a/drivers/xen/xen-acpi-processor.c >> +++ b/drivers/xen/xen-acpi-processor.c >> @@ -283,8 +283,8 @@ static int upload_pm_data(struct acpi_processor *_pr) >> if (_pr->flags.power) >> err = push_cxx_to_hypervisor(_pr); >> >> - if (_pr->performance && _pr->performance->states) >> - err |= push_pxx_to_hypervisor(_pr); >> + if (!err && _pr->performance && _pr->performance->states) >> + err = push_pxx_to_hypervisor(_pr); >> >> mutex_unlock(&acpi_ids_mutex); >> return err; > >