Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp700690ybl; Fri, 24 Jan 2020 08:01:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxn72DFW4osAPBUk9Gp2FG/U+fCQEWUns5F8wJaY/RdKrzcNECtYLL+yiRvZURzKzwWblnK X-Received: by 2002:aca:3241:: with SMTP id y62mr2371378oiy.31.1579881685664; Fri, 24 Jan 2020 08:01:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579881685; cv=none; d=google.com; s=arc-20160816; b=RAHr7nxdK/hkzBd/p63JLPzuQOGUhZyuticecqtMOj9ZRVdIozI1lYF68gCJV3Jcj0 DThHMGJ8vm0ilxSIzL/sN9YwAhuKgLyksyt5PnvMcWNqrD74B+0EbgQxk64w9cKXE2cu Ob4JnJRgs3aM2YADfQ8/x2J6K+tfE45etjCi/20DSezMdsNXVPGV22indLGDJnsPufx7 wPL1M9UTBCnsdNbzJVgjv91eRp5wcrBLoL01JyOA7d3Yl6zPE9CZiTWR1iFcs2NBC0W3 2an5Rf50Qkf+N0cw4KCAs3qDdh8YeOss7KuIg6nT/UcoDJq5jdduLl1clqw4VSv8qCgY ajEQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9vavgzp6FnEU55LIUhEDW0sNWxJyt+yzuMaiWvZ8IHE=; b=N4mToEN2yxw4KnD7PJqqjCzgZNB7uiVv905K3ze1qJAvMNzxrY/Zt1dHZV4XsT2ATB 8QY8Upxx+9MNRZCZixsV0VzUcJ/TORQKMB0L1pMR6hlqx0NOGbB+xX/s0PSEKpi+YFl+ 0R03RhY9/hQUruiZoF7v079D6qX9pXKKWGa2Y9u7PDfsCIIz4ljkTZgajpyLDpcVEHDU hXz8+L2fyj+pTaZgoCvTh3V0vVWUSJ6O9Ia4hDKLZvN7bDPFv+aPbEx34ym5q/2tqPfw xoHO6qhN2o/5SZsZfBdTHaXaWYq2OKaS/5wmoL8XHnxQ5Ukr0cAsqbSLpWJBe2Yx7aka WUSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vo99PXKq; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f194si2685076oig.243.2020.01.24.08.01.12; Fri, 24 Jan 2020 08:01:25 -0800 (PST) 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=@kernel.org header.s=default header.b=Vo99PXKq; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387761AbgAXLBm (ORCPT + 99 others); Fri, 24 Jan 2020 06:01:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:34628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731514AbgAXLBk (ORCPT ); Fri, 24 Jan 2020 06:01:40 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 099642075D; Fri, 24 Jan 2020 11:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579863699; bh=f5u5Esc9Dg6kRn/+Eea2oLe0Ud7hYJKU4FUVAAQPc58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vo99PXKqXF1dm508Pr4/DUmvfaFLrUWLqYO1BRNUNTsSnMvt5xdb/rHftfZCSM6Cm 75xZT+K8inn238uj+kA2KztzMYx/k0ehTwn+IkBDDlwtdObpa6MDXPrEJ+tJAJ4qo+ 2WiiA8E2juUoxlJO6ghlGJ6yaMiFoAH63a60JNb4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, YueHaibing , Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 051/639] powerpc/pseries/memory-hotplug: Fix return value type of find_aa_index Date: Fri, 24 Jan 2020 10:23:41 +0100 Message-Id: <20200124093053.800377097@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: YueHaibing [ Upstream commit b45e9d761ba2d60044b610297e3ef9f947ac157f ] The variable 'aa_index' is defined as an unsigned value in update_lmb_associativity_index(), but find_aa_index() may return -1 when dlpar_clone_property() fails. So change find_aa_index() to return a bool, which indicates whether 'aa_index' was found or not. Fixes: c05a5a40969e ("powerpc/pseries: Dynamic add entires to associativity lookup array") Signed-off-by: YueHaibing Reviewed-by: Nathan Fontenot nfont@linux.vnet.ibm.com> [mpe: Tweak changelog, rename is_found to just found] Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- .../platforms/pseries/hotplug-memory.c | 61 +++++++++---------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 7f86bc3eaadec..62d3c72cd9316 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -101,11 +101,12 @@ static struct property *dlpar_clone_property(struct property *prop, return new_prop; } -static u32 find_aa_index(struct device_node *dr_node, - struct property *ala_prop, const u32 *lmb_assoc) +static bool find_aa_index(struct device_node *dr_node, + struct property *ala_prop, + const u32 *lmb_assoc, u32 *aa_index) { - u32 *assoc_arrays; - u32 aa_index; + u32 *assoc_arrays, new_prop_size; + struct property *new_prop; int aa_arrays, aa_array_entries, aa_array_sz; int i, index; @@ -121,46 +122,39 @@ static u32 find_aa_index(struct device_node *dr_node, aa_array_entries = be32_to_cpu(assoc_arrays[1]); aa_array_sz = aa_array_entries * sizeof(u32); - aa_index = -1; for (i = 0; i < aa_arrays; i++) { index = (i * aa_array_entries) + 2; if (memcmp(&assoc_arrays[index], &lmb_assoc[1], aa_array_sz)) continue; - aa_index = i; - break; + *aa_index = i; + return true; } - if (aa_index == -1) { - struct property *new_prop; - u32 new_prop_size; - - new_prop_size = ala_prop->length + aa_array_sz; - new_prop = dlpar_clone_property(ala_prop, new_prop_size); - if (!new_prop) - return -1; - - assoc_arrays = new_prop->value; + new_prop_size = ala_prop->length + aa_array_sz; + new_prop = dlpar_clone_property(ala_prop, new_prop_size); + if (!new_prop) + return false; - /* increment the number of entries in the lookup array */ - assoc_arrays[0] = cpu_to_be32(aa_arrays + 1); + assoc_arrays = new_prop->value; - /* copy the new associativity into the lookup array */ - index = aa_arrays * aa_array_entries + 2; - memcpy(&assoc_arrays[index], &lmb_assoc[1], aa_array_sz); + /* increment the number of entries in the lookup array */ + assoc_arrays[0] = cpu_to_be32(aa_arrays + 1); - of_update_property(dr_node, new_prop); + /* copy the new associativity into the lookup array */ + index = aa_arrays * aa_array_entries + 2; + memcpy(&assoc_arrays[index], &lmb_assoc[1], aa_array_sz); - /* - * The associativity lookup array index for this lmb is - * number of entries - 1 since we added its associativity - * to the end of the lookup array. - */ - aa_index = be32_to_cpu(assoc_arrays[0]) - 1; - } + of_update_property(dr_node, new_prop); - return aa_index; + /* + * The associativity lookup array index for this lmb is + * number of entries - 1 since we added its associativity + * to the end of the lookup array. + */ + *aa_index = be32_to_cpu(assoc_arrays[0]) - 1; + return true; } static int update_lmb_associativity_index(struct drmem_lmb *lmb) @@ -169,6 +163,7 @@ static int update_lmb_associativity_index(struct drmem_lmb *lmb) struct property *ala_prop; const u32 *lmb_assoc; u32 aa_index; + bool found; parent = of_find_node_by_path("/"); if (!parent) @@ -200,12 +195,12 @@ static int update_lmb_associativity_index(struct drmem_lmb *lmb) return -ENODEV; } - aa_index = find_aa_index(dr_node, ala_prop, lmb_assoc); + found = find_aa_index(dr_node, ala_prop, lmb_assoc, &aa_index); of_node_put(dr_node); dlpar_free_cc_nodes(lmb_node); - if (aa_index < 0) { + if (!found) { pr_err("Could not find LMB associativity\n"); return -1; } -- 2.20.1