From patchwork Mon Jan 7 19:41:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 1942291 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A1F803FE37 for ; Mon, 7 Jan 2013 19:42:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755380Ab3AGTli (ORCPT ); Mon, 7 Jan 2013 14:41:38 -0500 Received: from perches-mx.perches.com ([206.117.179.246]:44975 "EHLO labridge.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755315Ab3AGTlg (ORCPT ); Mon, 7 Jan 2013 14:41:36 -0500 Received: from [173.51.221.202] (account joe@perches.com HELO [192.168.1.167]) by labridge.com (CommuniGate Pro SMTP 5.0.14) with ESMTPA id 20474881; Mon, 07 Jan 2013 11:41:35 -0800 Message-ID: <1357587696.21481.48.camel@joe-AO722> Subject: [PATCH] sunrpc: verbs: Avoid 1kb stack From: Joe Perches To: "J. Bruce Fields" , Trond Myklebust Cc: "David S. Miller" , linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 07 Jan 2013 11:41:36 -0800 X-Mailer: Evolution 3.6.0-0ubuntu3 Mime-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 16 * 64 is a bit much. Use kmalloc_array instead. Signed-off-by: Joe Perches --- net/sunrpc/xprtrdma/verbs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c index 745973b..9cfebb4 100644 --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c @@ -1736,8 +1736,13 @@ rpcrdma_register_default_external(struct rpcrdma_mr_seg *seg, int mem_priv = (writing ? IB_ACCESS_REMOTE_WRITE : IB_ACCESS_REMOTE_READ); struct rpcrdma_mr_seg *seg1 = seg; - struct ib_phys_buf ipb[RPCRDMA_MAX_DATA_SEGS]; int len, i, rc = 0; + struct ib_phys_buf *ipb = kmalloc_array(RPCRDMA_MAX_DATA_SEGS, + sizeof(*ipb), + GFP_KERNEL); + + if (!ipb) + return -ENOMEM; if (*nsegs > RPCRDMA_MAX_DATA_SEGS) *nsegs = RPCRDMA_MAX_DATA_SEGS; @@ -1770,6 +1775,9 @@ rpcrdma_register_default_external(struct rpcrdma_mr_seg *seg, seg1->mr_len = len; } *nsegs = i; + + kfree(ipb); + return rc; }