Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp586417img; Mon, 18 Mar 2019 09:42:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCMkfI5cBKol0dj8qjqgiCMbAleOGidd+fgZ5fV227UZ43Vn91RumrfdVp24ph/Y7MJkSW X-Received: by 2002:a17:902:e68e:: with SMTP id cn14mr20555674plb.67.1552927333864; Mon, 18 Mar 2019 09:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552927333; cv=none; d=google.com; s=arc-20160816; b=uEVpYNRJClKIoX8a8JYFO+ivLBneaZdw+76QPKKvu7I/NGd0pUq8s6AKbzZ13gyWcZ ES9uZPitvZw/44MLdy/qJFqoPJXn1c0cj3VSL55xp4beHaCp6ceYLCzF8tQTwFUjXrmI In3w0MQTwtv6fP1GifNUBSMjQWDP5ENE1Tqx+daqLqK+OqePnGSAeT6YcnMfzBI5diUZ bNV9/70/45LD65jb5slZqyz39dx0BjeOgZWOJ/s0skg2bIeL0SaXkSTSMfSB9eoun3z6 mpALUMbGitIaOo45tLPBTiUco1hBKRZPk8H7KqUzz1g0d/b/oeZr2psuQjbjcScTUYWK +ILw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Qf8VyBGM6BCT/mmVBZAC1dCuSDdDI/a+rLEIrUdaTPM=; b=igevRWEsAIZQALgYXqq0C+Es1Mb7lVBhtKGgUzVJ7ONZqW9f1IpkOfkybzQNU63ev6 kTjXuzCREYgZXEPCKXmgivUTXNDexdn3627/3zu3Rz5Zy8FPgR1GuWgCTNf8nFVEHiLB LsjgmjYCG2HXnRE4h995wTMmIprgKnb7eCVQL8NUmZhJE9/ZZ0/Ix7ah1ic0JVwZyjMa PmPeLb6EjtfU3zrxoMEu7WhVWbLX0eQr2R4ojDGphrElOF4s/B1Ol6c7rPVhCJGOhCsQ Qr3/1DVxPbvzEsz5AbBl3O2phMBGUbMk2mhMdqgJe5csoqFjGo3VwvE5m2mWSqvZawla 3ynw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SOuKwslX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j8si9596483plk.67.2019.03.18.09.41.58; Mon, 18 Mar 2019 09:42:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SOuKwslX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727791AbfCRQlF (ORCPT + 99 others); Mon, 18 Mar 2019 12:41:05 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43992 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726806AbfCRQlF (ORCPT ); Mon, 18 Mar 2019 12:41:05 -0400 Received: by mail-pg1-f196.google.com with SMTP id l11so11752937pgq.10 for ; Mon, 18 Mar 2019 09:41:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Qf8VyBGM6BCT/mmVBZAC1dCuSDdDI/a+rLEIrUdaTPM=; b=SOuKwslXC8uTauaIitnuKF3r0OTs6531kBIFlkX6Na6TisnAOtZMny7m5d2L7WMFLn Oj91HIheOrrKkwIEfVWdkDLBIr/uzjV9Eyv3q0tl/lkd7KTTmtY+HJwSVfFpPbkA22jJ EUIdcTl5+jY8L88orpux7EkS0KlKmCLL3ZzV9INU2XfzWYh9pIcHrhmJy38+ZYzI5izp kIT3cst//ARXr5ZZhvOa/78+5/Vf2gnTjCktnzoXDvKeaqXJ9//uBmbbLp9nTjjejo0y QnRXZewm/eoyyUdwxcM1vIqCh3mLQztZFoy6+ZgPtUOBHMR7QHqTOER5Y8q4AVDat31D rYTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Qf8VyBGM6BCT/mmVBZAC1dCuSDdDI/a+rLEIrUdaTPM=; b=XVbMqNzibT1+AloKPVlRx+oVhKdLiRzdxfU/XbWlxF2Id+zXTgbMV+A+0eEBOFuArw rdo1aT0JlTRGHkKjnSH+i7grDu+cDghAkgsgZvgdZpRAcWNeRvBMr54/z1Zha5rZ8Tvk AojSVPk0iR5pyyQpZJ/fflhUkrXLU3H1unKnjQPWDnOCd8WyBlJ01919J03lDAC7fuN2 FtF+HcMAMfadI+VUspT1WbXeh03hd6ytYkliewk4sAdemQV1g/ErvWc3l8sMOcdXjktr gA+V9FynIAonV/7LwjsqJf+XUUqHbeMhNEgJEI7tJytFYBx4Jm6se9EbMI1D7lPk1C9d okmg== X-Gm-Message-State: APjAAAWueWCoiMbqbKdCtbxw5c+AWz/D8Ej0QFp9HV3L5siDp4IgztL+ etaSVgM6R3ItCENkjeUoJCY= X-Received: by 2002:a17:902:9a02:: with SMTP id v2mr20818589plp.201.1552927264659; Mon, 18 Mar 2019 09:41:04 -0700 (PDT) Received: from [192.168.2.145] (ppp94-29-37-86.pppoe.spdop.ru. [94.29.37.86]) by smtp.googlemail.com with ESMTPSA id a66sm23028289pfj.153.2019.03.18.09.40.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 09:41:03 -0700 (PDT) Subject: Re: [PATCH v2] regulator: core: fix error path for regulator_set_voltage_unlocked To: Steve Twiss , Liam Girdwood , Mark Brown Cc: LKML , Maciej Purski , Support Opensource References: <20190318163132.1BB633FBA2@swsrvapps-01.diasemi.com> From: Dmitry Osipenko Message-ID: Date: Mon, 18 Mar 2019 19:40:55 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190318163132.1BB633FBA2@swsrvapps-01.diasemi.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 18.03.2019 19:17, Steve Twiss пишет: > During several error paths in the function > regulator_set_voltage_unlocked() the value of 'ret' can take on negative > error values. However, in calls that go through the 'goto out' statement, > this return value is lost and return 0 is used instead, indicating a > 'pass'. > > There are several cases where this function should legitimately return a > fail instead of a pass: one such case includes constraints check during > voltage selection in the call to regulator_check_voltage(), which can > have -EINVAL for the case when an unsupported voltage is incorrectly > requested. In that case, -22 is expected as the return value, not 0. > > Fixes: 9243a195be7a ("regulator: core: Change voltage setting path") > Cc: stable > Signed-off-by: Steve Twiss > --- > drivers/regulator/core.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c > index 68473d0..968dcd9 100644 > --- a/drivers/regulator/core.c > +++ b/drivers/regulator/core.c > @@ -3322,15 +3322,12 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator, > > /* for not coupled regulators this will just set the voltage */ > ret = regulator_balance_voltage(rdev, state); > - if (ret < 0) > - goto out2; > + if (ret < 0) { > + voltage->min_uV = old_min_uV; > + voltage->max_uV = old_max_uV; > + } > > out: > - return 0; > -out2: > - voltage->min_uV = old_min_uV; > - voltage->max_uV = old_max_uV; > - > return ret; > } > > Reviewed-by: Dmitry Osipenko