Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp377809pxj; Tue, 18 May 2021 05:34:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOEohfgvTzY8FY9qHHkXhCdIfbYVkFkkFZHxdyIazKtEjxsckWQs1xF+8aoL3yVcDay4h6 X-Received: by 2002:a17:906:fa0d:: with SMTP id lo13mr5949169ejb.477.1621341242596; Tue, 18 May 2021 05:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621341242; cv=none; d=google.com; s=arc-20160816; b=IyOdIiAs53/2VPL1oT3WcAK2UmKrrPlpyBGvi+TXpgbbd11ZhSzEGPYrUY+2pcWxZp d39mPqX92C4mlPEY1d5ZeH9KYQa8ws+IuqNgVQPXEHjW3ueWqNaU2058MhTp0Wqaptry seDEKbaIydEERzKOaYNXIZbU1UzTnWruBEBF/y0alAufyrtL9ZRDjIwEkm3XKZJAeqp6 SIKxPMTmdvYGwXA1LZGmfbGG+ubDnWLwn0BO3KbYYvpoHCtlqKepaQew42tQtNjkCSd5 0up16iRYPE4QFRuTlG4STV89kR8Yh95Tx8dNwAFIbSd5DQgnFGMt0sHD6JKV5ZNaxhdZ EczQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f2yHfcOQ85aIW3VTspNYLvgxjNkwAF6AeRTesxPdAIc=; b=fbdR/UHHj4CAnY97mx9r9A4Bd3r9vpYeHCliCdswNxSI0ePDcdGQIGVvf40edfDzCs pmtYPNfe6/znZ97Xqm/LPlU0xlcnNrc8S5vXAQkQgL7+mBCrQ8CWdfx3Whojl3E/l3/J 2PktbP23204BP+kZogtcllnxYESJYOrSGf7LZIkXzh3UPz0OUkPLAImOYE/H++5/K8DS F5NjrxJ0SfZPRQMHBH3xuXu4BrvYp4eBSEfseEvT6MwoMwJsiW5HHbE19t9nHjBvTjrc R5KS6kmBpj1ANl9ONm6EEf3m9qjw1HGRXVlOVUjTDYVnk83u42Aa6orkqh5xdUZf1MNf OnmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GlJZROmt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n2si16849864eda.470.2021.05.18.05.33.39; Tue, 18 May 2021 05:34:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GlJZROmt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244428AbhEQPbM (ORCPT + 99 others); Mon, 17 May 2021 11:31:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:56032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242866AbhEQPQi (ORCPT ); Mon, 17 May 2021 11:16:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B11C6187E; Mon, 17 May 2021 14:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261978; bh=KhNrqEckrBWrYbxQW5GdiVG9iEMlzpG4HJaVP3aEKtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GlJZROmtBueK7wMhUZtuED34CFTKhur+PPvGr0jaVEcX7xrXO2QHv5oYC/628FgRT VPbM6RxgiuMfC7tmmyKXyiTjQPRtXRFzd2PZDgd7jmyYwoqtpbchCNgeP60l+RtT19 gIq8frq3Jm43foSPY/AtXnJOo3qzskE8crrtBDoM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, TOTE Robot , Jia-Ju Bai , Daniel Lezcano , Sasha Levin Subject: [PATCH 5.10 094/289] thermal: thermal_of: Fix error return code of thermal_of_populate_bind_params() Date: Mon, 17 May 2021 16:00:19 +0200 Message-Id: <20210517140308.351364018@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit 45c7eaeb29d67224db4ba935deb575586a1fda09 ] When kcalloc() returns NULL to __tcbp or of_count_phandle_with_args() returns zero or -ENOENT to count, no error return code of thermal_of_populate_bind_params() is assigned. To fix these bugs, ret is assigned with -ENOMEM and -ENOENT in these cases, respectively. Fixes: a92bab8919e3 ("of: thermal: Allow multiple devices to share cooling map") Reported-by: TOTE Robot Signed-off-by: Jia-Ju Bai Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20210310122423.3266-1-baijiaju1990@gmail.com Signed-off-by: Sasha Levin --- drivers/thermal/thermal_of.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 69ef12f852b7..5b76f9a1280d 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -704,14 +704,17 @@ static int thermal_of_populate_bind_params(struct device_node *np, count = of_count_phandle_with_args(np, "cooling-device", "#cooling-cells"); - if (!count) { + if (count <= 0) { pr_err("Add a cooling_device property with at least one device\n"); + ret = -ENOENT; goto end; } __tcbp = kcalloc(count, sizeof(*__tcbp), GFP_KERNEL); - if (!__tcbp) + if (!__tcbp) { + ret = -ENOMEM; goto end; + } for (i = 0; i < count; i++) { ret = of_parse_phandle_with_args(np, "cooling-device", -- 2.30.2