From patchwork Mon Jun 29 14:50:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Hubbe X-Patchwork-Id: 489326 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C91DC140759 for ; Tue, 30 Jun 2015 00:51:00 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=emc.com header.i=@emc.com header.b=dHPTaIGC; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753320AbbF2Ou6 (ORCPT ); Mon, 29 Jun 2015 10:50:58 -0400 Received: from mailuogwhop.emc.com ([168.159.213.141]:58777 "EHLO mailuogwhop.emc.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752903AbbF2Ouk (ORCPT ); Mon, 29 Jun 2015 10:50:40 -0400 Received: from maildlpprd05.lss.emc.com (maildlpprd05.lss.emc.com [10.253.24.37]) by mailuogwprd01.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id t5TEoTwl026704 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 29 Jun 2015 10:50:31 -0400 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd01.lss.emc.com t5TEoTwl026704 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=emc.com; s=jan2013; t=1435589431; bh=NOk466x8z2MZuQ3pUMbNoFBdb7A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: In-Reply-To:References; b=dHPTaIGCh28E9FsiBGwGIE5rhCyVynkft/K8sbI6H8zFhVO4OeueCEmSSTcvn4f7c V6Csi9PG1sBFx8LySh7oS7iKjPPrFGIQwQW1DUCxbzS14NZbbWnErPBdUPS3HPZ7AH Twlns+ephRDDzeC3osgIaiN/EmoBUA5ab9imtrLY= X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd01.lss.emc.com t5TEoTwl026704 Received: from mailapphubprd54.lss.emc.com (emcmail.lss.emc.com [10.106.83.173]) by maildlpprd05.lss.emc.com (RSA Interceptor); Mon, 29 Jun 2015 10:50:02 -0400 Received: from HY-R1012-SPA.usd.lab.emc.com.com (hy-r1012-spa.rtp.lab.emc.com [10.6.71.221]) by mailapphubprd54.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id t5TEoGFj000374; Mon, 29 Jun 2015 10:50:19 -0400 From: Allen Hubbe To: linux-ntb@googlegroups.com Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Jon Mason , Dave Jiang , Allen Hubbe Subject: [PATCH 5/9] NTB: Fix oops in debugfs when transport is half-up Date: Mon, 29 Jun 2015 10:50:01 -0400 Message-Id: X-Mailer: git-send-email 2.4.0.rc0.44.g244209c.dirty In-Reply-To: References: In-Reply-To: References: X-RSA-Classifications: public X-Sentrion-Hostname: mailuogwprd01.lss.emc.com Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Dave Jiang When the remote side is not up, we do not have all the context for the transport, and that causes NULL ptr access. Have the debugfs reads check to see if transport is up before we make access. Signed-off-by: Dave Jiang --- drivers/ntb/ntb_transport.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c index 30d8b52421ec..1764bb2fd265 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c @@ -438,13 +438,17 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count, char *buf; ssize_t ret, out_offset, out_count; + qp = filp->private_data; + + if (!qp || !qp->link_is_up) + return 0; + out_count = 1000; buf = kmalloc(out_count, GFP_KERNEL); if (!buf) return -ENOMEM; - qp = filp->private_data; out_offset = 0; out_offset += snprintf(buf + out_offset, out_count - out_offset, "NTB QP stats\n");