Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3436326imu; Sun, 11 Nov 2018 15:04:07 -0800 (PST) X-Google-Smtp-Source: AJdET5d53O8u4YqLgyqc/kN+FoidMEYkqdK1h4aNaeHJJRJeruYJMh/xJRSyYO02lzwreBqK4Lij X-Received: by 2002:a63:7f4f:: with SMTP id p15mr1965760pgn.296.1541977447270; Sun, 11 Nov 2018 15:04:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977447; cv=none; d=google.com; s=arc-20160816; b=BW/7W0ziqEDlvH3zXeQGQ2lfyMFEtTsVaNIVnV3rJs+Vm7FuFkZPfKO2zy9rRnMOnB Od/GA/Ra0OaL48y8/ZTPbiLp3AyNYXqQdivXP6+MD03yjI15JhtndYyVO85A+zx1bc4g fPAXxoJ3xcRAOp3HOT0fWHOfSz+IXMRlZKJYx4KJpBR/fnGKMIu9Kh6k1PdlxAmyLn2B 99vKDtbPMgOiyl6t9yS+OWuy98u9XveZCNjbB+U4/jdgEHzqOkYJGJ45w51lBYAOCsMd LqxX0A43YSPuP++4Z/4n86hSTGa6rOSMzTGS5ddcHG6Vj144YH0RpBwOnSn4ReGFGlLb JkOA== 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=wQnY50HJi3dZaCUZKsXtJKUPyzNwdULdlz9JZRAtvSc=; b=QyeggReqTw6rUmv/Zka3djtiQ3jS2sNERQi9qB+rf+4YSV427XtnmjzYt7bzLFJvze jVTIF6ZOiej6jdeRrWguewEryXLet+6nCzgTOi3CD2kSdGnY+WfSuGm8AXEeernNPNd/ eUOPN/be3ZA3hNhK42tYtCze1MQLBCSwFpH6cuzgI/joodvjvutRbmCOWRHDzte8hzL3 cOZ6WqayneKy7c/V68gBANhFnRyk+X8Xb77C89/j49FBdlFUjpaWwhbZxWIT2r3DN24i xlRfK0kLqf9Yy0tPGl7lb7dE2DiRrsiQm3CEoGK2ntIULKi+PcTdrvz/8xwERVgM8E8m ckRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vuk6YSPQ; 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 i63si14467228pge.515.2018.11.11.15.03.51; Sun, 11 Nov 2018 15:04:07 -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=vuk6YSPQ; 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 S2390639AbeKLIxd (ORCPT + 99 others); Mon, 12 Nov 2018 03:53:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:51200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390556AbeKLIWY (ORCPT ); Mon, 12 Nov 2018 03:22:24 -0500 Received: from localhost (unknown [206.108.79.134]) (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 10B0421508; Sun, 11 Nov 2018 22:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975547; bh=z3jM/vhLcSgleTrvsyy4ZEZ87hUjuW1dDF3PvaP5IY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vuk6YSPQOc1RWfsAzhRqb8uXDjmdCol87S4AtHUIC8cyYjHxxGGoJ6c8nrUnfLqpU OG7BY4BZzWmoxk7GiEhHRe01+3bXlxArGRlz9jtYik0Rbbg4bvSHaQ0NH+8abks7zA 7MnMTRkBDW/IEwO8YQIuIWEC7eNqiQS1RtXOzisg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Holger=20Hoffst=C3=A4tte?= , Parav Pandit , Leon Romanovsky , Doug Ledford , Sasha Levin Subject: [PATCH 4.14 081/222] RDMA/core: Do not expose unsupported counters Date: Sun, 11 Nov 2018 14:22:58 -0800 Message-Id: <20181111221655.279528909@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Parav Pandit [ Upstream commit 0f6ef65d1c6ec8deb5d0f11f86631ec4cfe8f22e ] If the provider driver (such as rdma_rxe) doesn't support pma counters, avoid exposing its directory similar to optional hw_counters directory. If core fails to read the PMA counter, return an error so that user can retry later if needed. Fixes: 35c4cbb17811 ("IB/core: Create get_perf_mad function in sysfs.c") Reported-by: Holger Hoffstätte Tested-by: Holger Hoffstätte Signed-off-by: Parav Pandit Signed-off-by: Leon Romanovsky Signed-off-by: Doug Ledford Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/sysfs.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -489,7 +489,7 @@ static ssize_t show_pma_counter(struct i ret = get_perf_mad(p->ibdev, p->port_num, tab_attr->attr_id, &data, 40 + offset / 8, sizeof(data)); if (ret < 0) - return sprintf(buf, "N/A (no PMA)\n"); + return ret; switch (width) { case 4: @@ -1012,10 +1012,12 @@ static int add_port(struct ib_device *de goto err_put; } - p->pma_table = get_counter_table(device, port_num); - ret = sysfs_create_group(&p->kobj, p->pma_table); - if (ret) - goto err_put_gid_attrs; + if (device->process_mad) { + p->pma_table = get_counter_table(device, port_num); + ret = sysfs_create_group(&p->kobj, p->pma_table); + if (ret) + goto err_put_gid_attrs; + } p->gid_group.name = "gids"; p->gid_group.attrs = alloc_group_attrs(show_port_gid, attr.gid_tbl_len); @@ -1128,7 +1130,8 @@ err_free_gid: p->gid_group.attrs = NULL; err_remove_pma: - sysfs_remove_group(&p->kobj, p->pma_table); + if (p->pma_table) + sysfs_remove_group(&p->kobj, p->pma_table); err_put_gid_attrs: kobject_put(&p->gid_attr_group->kobj); @@ -1240,7 +1243,9 @@ static void free_port_list_attributes(st kfree(port->hw_stats); free_hsag(&port->kobj, port->hw_stats_ag); } - sysfs_remove_group(p, port->pma_table); + + if (port->pma_table) + sysfs_remove_group(p, port->pma_table); sysfs_remove_group(p, &port->pkey_group); sysfs_remove_group(p, &port->gid_group); sysfs_remove_group(&port->gid_attr_group->kobj,