From patchwork Thu Dec 3 21:41:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Marciniszyn, Mike" X-Patchwork-Id: 7763831 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CF9B8BEEE1 for ; Thu, 3 Dec 2015 21:41:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 12A73205E7 for ; Thu, 3 Dec 2015 21:41:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31BB7205EC for ; Thu, 3 Dec 2015 21:41:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752046AbbLCVlI (ORCPT ); Thu, 3 Dec 2015 16:41:08 -0500 Received: from mga11.intel.com ([192.55.52.93]:10773 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750862AbbLCVlH (ORCPT ); Thu, 3 Dec 2015 16:41:07 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 03 Dec 2015 13:41:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,378,1444719600"; d="scan'208";a="853450609" Received: from sedona.ch.intel.com ([143.182.228.65]) by fmsmga001.fm.intel.com with ESMTP; 03 Dec 2015 13:41:06 -0800 Received: from phlsvsles11.ph.intel.com (phlsvsles11.ph.intel.com [10.228.195.43]) by sedona.ch.intel.com (8.13.6/8.14.3/Standard MailSET/Hub) with ESMTP id tB3Lf6s3022590; Thu, 3 Dec 2015 14:41:06 -0700 Received: from phlsvslse11.ph.intel.com (localhost [127.0.0.1]) by phlsvsles11.ph.intel.com with ESMTP id tB3Lf5OW006125; Thu, 3 Dec 2015 16:41:05 -0500 Subject: [PATCH] staging/rdma/hfi1: fix sdma build failures to always clean up To: devel@driverdev.osuosl.org From: Mike Marciniszyn Cc: linux-rdma@vger.kernel.org, dledford@redhat.com, linux-next@vger.kernel.org Date: Thu, 03 Dec 2015 16:41:05 -0500 Message-ID: <20151203214105.6103.23333.stgit@phlsvslse11.ph.intel.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are holes in the sdma build support routines that do not clean any partially built sdma descriptors after mapping or allocate failures. This patch corrects these issues. Reviewed-by: Dennis Dalessandro Signed-off-by: Mike Marciniszyn --- drivers/staging/rdma/hfi1/sdma.c | 10 ++++++---- drivers/staging/rdma/hfi1/sdma.h | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" 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/drivers/staging/rdma/hfi1/sdma.c b/drivers/staging/rdma/hfi1/sdma.c index 90b7072..8023eeb 100644 --- a/drivers/staging/rdma/hfi1/sdma.c +++ b/drivers/staging/rdma/hfi1/sdma.c @@ -2724,22 +2724,21 @@ static int _extend_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx) tx->coalesce_buf = kmalloc(tx->tlen + sizeof(u32), GFP_ATOMIC); if (!tx->coalesce_buf) - return -ENOMEM; - + goto enomem; tx->coalesce_idx = 0; } return 0; } if (unlikely(tx->num_desc == MAX_DESC)) - return -ENOMEM; + goto enomem; tx->descp = kmalloc_array( MAX_DESC, sizeof(struct sdma_desc), GFP_ATOMIC); if (!tx->descp) - return -ENOMEM; + goto enomem; /* reserve last descriptor for coalescing */ tx->desc_limit = MAX_DESC - 1; @@ -2747,6 +2746,9 @@ static int _extend_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx) for (i = 0; i < tx->num_desc; i++) tx->descp[i] = tx->descs[i]; return 0; +enomem: + sdma_txclean(dd, tx); + return -ENOMEM; } /* diff --git a/drivers/staging/rdma/hfi1/sdma.h b/drivers/staging/rdma/hfi1/sdma.h index 85701ee..da89e64 100644 --- a/drivers/staging/rdma/hfi1/sdma.h +++ b/drivers/staging/rdma/hfi1/sdma.h @@ -774,10 +774,13 @@ static inline int _sdma_txadd_daddr( tx->tlen -= len; /* special cases for last */ if (!tx->tlen) { - if (tx->packet_len & (sizeof(u32) - 1)) + if (tx->packet_len & (sizeof(u32) - 1)) { rval = _pad_sdma_tx_descs(dd, tx); - else + if (rval) + return rval; + } else { _sdma_close_tx(dd, tx); + } } tx->num_desc++; return rval;