Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3655212rdh; Mon, 27 Nov 2023 23:09:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVn7i1c6bLCsEx8zKxMXXFQgtQ/ObMIRnevulJcD1hCpz8NyeryXemO37eBvJ7vOjpg+/r X-Received: by 2002:a05:6e02:b4a:b0:35c:f500:cfa1 with SMTP id f10-20020a056e020b4a00b0035cf500cfa1mr4693991ilu.29.1701155374542; Mon, 27 Nov 2023 23:09:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701155374; cv=none; d=google.com; s=arc-20160816; b=Mq5yN66PmWm0gEwx8QIViLTlHCjMvTTqQ4gbWPP/70PYiDRGwVgRXYbHlpO8yiJ6vX I5nB5eB/G7dvgzrzkkvuF0XDqSj7ZquIt8pahSnnOWdrjzgXkoMEhlb01/HrAyo3ODb4 0wFzAP8CGpJFCaKyNAugxoQ+GQt+/qH3ixmNdAHbqMBB+lwtL8C0lRMGsXzP60z/EsfL 4b4JaVyucS7g7+HK+YCQZmdk1V7m/movb0GyoF/5G7k003YMBVXYq/v00C9y4+NndHLl dL5HwEAr4T/jp+emARlRQJWEID+J1OVfITNiCRqAbcd0NEQcwpgYOAf9j8H48RYd7jP5 FRJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3DfVtya4RBsfO21aPZQimz87Ty2xKQDd/O6zJS+ytuc=; fh=1/6QhXf8g1DqpYfksEXKPI44bC/auJjRo7Vs9w2UGKU=; b=P06K1x5+Lv7T36v0eVjGwx2G5BCOre3n6S8ff8f1KIE4QhWfEFJihSCI3jJnE/mhKZ 904nQMRY1Cxx6BL/jVXBbFjksBFG46l0Lbv2JgGuz0soFhDtvHUu15LtqWoJCtobhoyD +InAyd4686niSW49Mc5JdTBBAQMvjVbNjhg/zUyOJnaBaDPUzk6I94gIU9Hw2FARXDpR yCMDQTTWp3K33SrHuE/U63av2C78LJDoNTLFrOIUN4ArVrTGFI5hCR050oGqK5CEuEOI WqLZa9SJbFQmry1USgEJjXeB23E2tiLfUPWffQ4QyK0GlXkqGaq9296FzSsDaqHOE1+C 2aEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BrkX1gFF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z7-20020a631907000000b005c1b2d6aa3esi11660152pgl.355.2023.11.27.23.09.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 23:09:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BrkX1gFF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 06AE68058C4E; Mon, 27 Nov 2023 23:09:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343709AbjK1HJJ (ORCPT + 99 others); Tue, 28 Nov 2023 02:09:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343699AbjK1HJI (ORCPT ); Tue, 28 Nov 2023 02:09:08 -0500 Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB835182 for ; Mon, 27 Nov 2023 23:09:14 -0800 (PST) Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-58d54612d9cso1546069eaf.1 for ; Mon, 27 Nov 2023 23:09:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701155354; x=1701760154; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3DfVtya4RBsfO21aPZQimz87Ty2xKQDd/O6zJS+ytuc=; b=BrkX1gFFbVKElH0gabTl1nw2cvkPGbYPoO0dTp39wLntPiyY/Xi1yew3opTJe5gQSl prN3QNlqBWAv1rPjoVsFHKS6Oqvn6ttSfEvsN0zN6fomGBRdulnfGHcYuc7Sr+xGpscN H5siQDf6kJ5YQa3D1VXRlpNs8hGc+kv7Q7wn2UGmI1P8opQWUtZNi1pqHh0KfCrJnzE/ JDhmQa6gKg/UczkneuvHC80zEjF3gQIWTRI71N7oa+ADOEDbC4WyjqiY92ipLUpoVllh lQZ/YGVUBECVbtItcf8g1I0F88rtK8t6Z9Wb8GyjH7Vpku7U4wqZGW6De/jHUariA5+q vQLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701155354; x=1701760154; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3DfVtya4RBsfO21aPZQimz87Ty2xKQDd/O6zJS+ytuc=; b=vvJiQztWOwwgD5XNLjwPN6EF6Y2RP9KP/76pBCrEhdxeUsl3680l4Jgk7+8A7CjRVW RIX/FaH4wZFvjkDfWHdnXdcg89o6g5XpiNBetLN3VcTJ98A4ZxpOSPF7KGUvsLHQvH7j Af6StH5rGnGql4ZhXr1RoSXmeWWD0kRqI/CiMc79Prg1jDm0d9YvbshVW3x1/uLVYgBn ML0Hzg0rs7YQBQ6RgBOgOcllpndcU4w8lFS5779TjGpZ6lS1pOHw6MIr3DDJsA34coQ9 HcCQIT4bgWgtuSHmJpUhFQnxgbxsbhHzxXpL2N257qIEsFGN97k8+jxxvNd0wCI55jqm KWPQ== X-Gm-Message-State: AOJu0YwesOh3sCz2AT8kyI5ndvefZOhSr+nBhRzcyAZ/U/EpZQouY7jB SfaQ1/iKIPsICDXpjXV7pyAxeQ== X-Received: by 2002:a05:6820:60a:b0:58d:9c58:428e with SMTP id e10-20020a056820060a00b0058d9c58428emr4726750oow.5.1701155353956; Mon, 27 Nov 2023 23:09:13 -0800 (PST) Received: from localhost ([122.172.82.6]) by smtp.gmail.com with ESMTPSA id o18-20020a63e352000000b005b1bf3a200fsm9070147pgj.1.2023.11.27.23.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 23:09:13 -0800 (PST) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd , Ulf Hansson Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Dan Carpenter , linux-kernel@vger.kernel.org Subject: [PATCH] OPP: Check for invalid OPP in dev_pm_opp_find_level_ceil() Date: Tue, 28 Nov 2023 12:39:06 +0530 Message-Id: <51b7d5dec3d4f3a677b355b12fac9dcac63828cf.1701155328.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 27 Nov 2023 23:09:24 -0800 (PST) _find_key_ceil() may return an error and that must be checked before passing the same to dev_pm_opp_put(). Fixes: 41907aa4ae37 ("OPP: Level zero is valid") Reported-by: Dan Carpenter Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 4f1ca84d9ed0..c022d548067d 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -808,6 +808,8 @@ struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct device *dev, struct dev_pm_opp *opp; opp = _find_key_ceil(dev, &temp, 0, true, _read_level, NULL); + if (IS_ERR(opp)) + return opp; /* False match */ if (temp == OPP_LEVEL_UNSET) { -- 2.31.1.272.g89b43f80a514