Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3480813imu; Sun, 11 Nov 2018 16:04:43 -0800 (PST) X-Google-Smtp-Source: AJdET5ebTCok+tYCVhRygdekzIFXrNMK0pgnHm71g12w3YNNEHkQX9OdaLlQ3gSD6fUcAoedPgpa X-Received: by 2002:a17:902:4503:: with SMTP id m3-v6mr17926673pld.217.1541981083925; Sun, 11 Nov 2018 16:04:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981083; cv=none; d=google.com; s=arc-20160816; b=C0jQLwF+GIUSV5oZeLZyDkHTKXS9eT4mNV8aMvqcucxM8W/2P8ulnTMBCSCobrSFZf e8CZdeDt7SsZLym4P0X40CY0aRqkXkgSpM+ePxGt/hYcjeCmJPN2rMUYITd0EEGJ47Gt z9ZOAxPZhAf6aRvoKMl2M6lg6nA2JUtxqOSLtoi8YrSpZWx55TVNhdQiwpGEa2SCWizc XoegRBRva2JxNsuJz5wSOmeqJji3f1Yc7/H7gK0V9EbTQin8ilOlD/UumpKMXGxAU9al 4TJwfEl+f7Kup3lqT1GNhf40v0C7Zmc5A2WZeCBeA9pcmsv6DtUPJ/+cFf7AdBZ9vOXs WTCw== 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=0fv/r9pz7y5heFwfQ/LTxwFn87oq/FH4NADujAG0q4k=; b=ZlkEUdHQyIi7+TbsF9gU31mFEt9Zvg3y1jS0S3t77Fp4rCJsmBTe0LacC+DqrsdNFV k2TYhBi8Jc5pLS5c85QwG8zWzp3aYHLP4u75J9viZ5Rk7+QWp/sFvYX4/3iQscpa7k8J PlekvPwUw09XxpvNlv74P5Sk7d8TFwJfKDhEl+JfYbFJ+E4Roh/ii2IIBrN6XG7hblEK MUyZZs8wkrsgyMHlGoeMSmCp30kmdyS9jWeHXnq+LGqOq60IbwOeNjxp6NGF4+3awIIv KKpYGojFXyreFhWRdu115B8dsJ4iPJ2Kg86ImOz8y4PszeeXfZS1gDF+vEImJvzIZTVF R4Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cQAluPxh; 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 t64-v6si17154564pfd.58.2018.11.11.16.04.28; Sun, 11 Nov 2018 16:04:43 -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=cQAluPxh; 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 S1732277AbeKLJyc (ORCPT + 99 others); Mon, 12 Nov 2018 04:54:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:34210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732053AbeKLIRs (ORCPT ); Mon, 12 Nov 2018 03:17:48 -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 A3AC5223CE; Sun, 11 Nov 2018 22:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975272; bh=PD2bNtkcOiQjKDEUzOd1byEm/0WblSAVXZIz8P/CgaM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cQAluPxhzsHyzU4tuxooP1qInNgRu8fcKjKDvneHRnZeddn4pen/5ySIBnHH01yid EX/ZWfsmM+2OLdwpY2Z09UZIpHtMzOmAEtG1HHNO0/HlvC7GcmqwY4bA48PxAz7uX9 6ZGbdZ4WCSAS2Hqx9gq3SzxXcNciwTmdYszk+Wwo= 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.19 142/361] RDMA/core: Do not expose unsupported counters Date: Sun, 11 Nov 2018 14:18:09 -0800 Message-Id: <20181111221640.418091820@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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 @@ -512,7 +512,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: @@ -1057,10 +1057,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); @@ -1173,7 +1175,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); @@ -1285,7 +1288,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,