Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp557472img; Mon, 18 Mar 2019 09:04:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZ4TxiT5JyQFZtg9ZEg6lp5WKh//56witDV4jR/wRySuCnNeAHRju/NFi4yVDaXhLV6tMN X-Received: by 2002:a17:902:be09:: with SMTP id r9mr20724760pls.189.1552925087729; Mon, 18 Mar 2019 09:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552925087; cv=none; d=google.com; s=arc-20160816; b=dND3190++3mgA50ylaEkjLNOihoVx6YpDb6hLtFlYHQjlNPi+UFt6HuiZGi+EF4iOp sh65Bx8fOePz5G0IB220yCpTvDFiXZPHPWlOo3SBV+YoQ1/sGVGKiqWBVVdE75cbrOfs IL4JgvTLdGqKFrmsVkXoxDw297SSYNYuqnF0Pz3qewMDk7+nGqW1DPE+mSctNBSgMvBB KA7f4BIDz/AqqPjP2uuvQyUK70GsbLexVM6R5Uk1GWQKeuHZFZnpYungErDH3Q7qNGb4 hqToI83aVsViiL2Eh4O2jEiBpTOmbidxx3a8ZagRikCxMuOBWH6END05GCGJhUR2M8/L 5eyg== 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=G25m8+9f1ygSfASWU0CeM8DWXCHa+R6w3/Ew9+fOBT4=; b=aYTbMAaGLoPwNb74mZHFD6wlXFJOPd33gFc1SybURoLLX+9Wtwyd99AODqOesArS5A p3+vLOkwccbe32qA79j2l/YFj5k+hT/cLErd9k83iF+utdnlE+VNcOu/knrxeF31nuQy +kxW4WBZUv2dDWdReO9q9kBFUrNpFK8/TtE8/QIMxYWRwvF8vnE1AUOShiQ+VXg+itrc Yh2R66YQqxiizA0J0Pp1KVhsPc0hUbJLCdYmEOd9tHUZ03o7YK6xy1Rqtdk7j5SR6x4y 7DEETpe3H0qI8rd0umQSdB+BjFSK7VAiSXpz3pdzW1xaEuZubCFIDENcnvefShSlfFbs gT5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NfdPy5h5; 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 o8si9528828pgl.23.2019.03.18.09.04.31; Mon, 18 Mar 2019 09:04:47 -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=NfdPy5h5; 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 S1727397AbfCRQDa (ORCPT + 99 others); Mon, 18 Mar 2019 12:03:30 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33032 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726719AbfCRQDa (ORCPT ); Mon, 18 Mar 2019 12:03:30 -0400 Received: by mail-pg1-f194.google.com with SMTP id i7so8482513pgq.0 for ; Mon, 18 Mar 2019 09:03:29 -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=G25m8+9f1ygSfASWU0CeM8DWXCHa+R6w3/Ew9+fOBT4=; b=NfdPy5h5vrXvbG3AasrACo8iuyrXTHLtVT7H6CgVhSF7Xzqn1DZWHQqe3F/V/eN/FV tFzUUr20nk1koe0Z2W+MNxvGbsX5CaHeVwx28iXKV5Rzw2zyWNW4cYK4wJX93l1nmZUD K515rzXeXGhq5JY7aGrAVjbPxSqdA6Js2/1tshV92OWsk/M2d4UeEW8aGswq0UJ+zVxk 4bvizxX7oWL1RYnL0yTIDEyWipZkFDjwLoVgeFAlQZOK1C5Fx/syiXdH+HhNaRX6WnVq kHNEhZyutcfJD1MZizdxoRVVljTo4y1s+iks+LyQnYrlaJgBrsGNNP66mT9jHuxVzQQK do7A== 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=G25m8+9f1ygSfASWU0CeM8DWXCHa+R6w3/Ew9+fOBT4=; b=seZMcHDUGiT7v/u3O4NosKjXoT4KmPcVDygHR9qICtNHbM0Kozv7zlYZ3BVCd0FEXV CJX8sRC0F4Y4RYepyoNp/35ztv4wnriDm3Jx04EN7dTpeKTSkHtQ/ql9KJVvWF+sAzlH hj7YQDfMnVz2hw3laTvxPbFxNnK2M97oSYk/6sXWnaRLuQ78v5KRDA5UU3gLmQfVHxEI CL6ap+MBAwar5gzCTlfP5s2Rr2x7VdyvT3DqcO8iiaKU3dJd08yVTWE97L5bWa1Rwty/ NTwTrHmVo5ddtZyUrQdFY1xY2OZCdSRVxTW+81jQJXpTjHySo62DiYU2OWG7Q/Bsci75 tEyA== X-Gm-Message-State: APjAAAVMhj4eXV2YwJmmiIbEv/AIE497h3v/ipvVDi1mK1Kdyym/tdov zfFLOaATgR/TIXp24fwDNfk= X-Received: by 2002:a65:6299:: with SMTP id f25mr18449831pgv.376.1552925008812; Mon, 18 Mar 2019 09:03:28 -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 j14sm16204886pfn.77.2019.03.18.09.03.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 09:03:28 -0700 (PDT) Subject: Re: [PATCH] regulator: core: fix error path for regulator_set_voltage_unlocked To: Steve Twiss , Liam Girdwood , Mark Brown Cc: LKML , Maciej Purski , Support Opensource References: <20190318155054.59B483FBD8@swsrvapps-01.diasemi.com> From: Dmitry Osipenko Message-ID: <513a7028-b972-a821-7bf1-0e105bf71305@gmail.com> Date: Mon, 18 Mar 2019 19:03:19 +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: <20190318155054.59B483FBD8@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 18:32, 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") > Signed-off-by: Steve Twiss > --- > drivers/regulator/core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c > index 68473d0..caf8743 100644 > --- a/drivers/regulator/core.c > +++ b/drivers/regulator/core.c > @@ -3326,7 +3326,7 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator, > goto out2; > > out: > - return 0; > + return ret; > out2: > voltage->min_uV = old_min_uV; > voltage->max_uV = old_max_uV; > Looks like a good catch. Probably will be a bit better to write this as: /* 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; }