From patchwork Sat Nov 29 17:21:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tina Johnson X-Patchwork-Id: 5406931 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 41C0EBEEA8 for ; Sat, 29 Nov 2014 17:23:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3DFB420145 for ; Sat, 29 Nov 2014 17:23:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4996A20138 for ; Sat, 29 Nov 2014 17:23:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751351AbaK2RXW (ORCPT ); Sat, 29 Nov 2014 12:23:22 -0500 Received: from mail-pd0-f177.google.com ([209.85.192.177]:40552 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751043AbaK2RXV (ORCPT ); Sat, 29 Nov 2014 12:23:21 -0500 Received: by mail-pd0-f177.google.com with SMTP id ft15so8152090pdb.8 for ; Sat, 29 Nov 2014 09:23:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=WLSLD7Mo0gKzDjtzPaYIfobzQ5ERXUbgvy1Nrfh754Y=; b=srjLDaULq1+4E6PcO0R6Cej0UG6Vd0yJOk9T5lfwmgZCf3r5M3mirSck759Muc2iMz DUXhWhQ6KzDvwhi8xMs86YPLIkf8PrNyuIyyvtHt7RRy+FDwvUV0K0TNbOkw+QPz4k1Q rIsblOuvptoyBfmDRTjOisLvfemJhtdqdPgQsRBtM5z45Pa7Rj/KI9lh/R9jY2EDR9EH 6PmqYlJM8c/DSnnyt8A+9+WYUldv1IW0sxDgLEjlwEaZI5wI8Lm2MI2Xdr/NmwFMEWar LNPrhkHWLmibkmiujnGhmHVklOQtSehhoop6mwya7Qja3wRzdHeiaHXp6ItgGWBbUAer SpVg== X-Received: by 10.70.124.162 with SMTP id mj2mr84145236pdb.33.1417281801386; Sat, 29 Nov 2014 09:23:21 -0800 (PST) Received: from localhost ([117.252.19.130]) by mx.google.com with ESMTPSA id ny9sm13173333pab.25.2014.11.29.09.23.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 29 Nov 2014 09:23:20 -0800 (PST) From: Tina Johnson To: tom@opengridcomputing.com Cc: swise@opengridcomputing.com, linux-rdma@vger.kernel.org, julia.lawall@lip6.fr, Tina Johnson Subject: [PATCH] drivers: infiniband: hw: Add pci_dma_mapping_error() call Date: Sat, 29 Nov 2014 22:51:17 +0530 Message-Id: <1417281677-7133-1-git-send-email-tinajohnson.1234@gmail.com> X-Mailer: git-send-email 1.7.10.4 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Added a pci_dma_mapping_error() call to check for mapping errors before further using the dma handle. The previously allocated skb is freed in case of a mapping error. Unchecked dma handles were found using Coccinelle: @rule1@ expression e1; identifier x; @@ *x = pci_map_single(...); ... when != pci_dma_mapping_error(e1,x) Signed-off-by: Tina Johnson Acked-by: Julia Lawall --- drivers/infiniband/hw/amso1100/c2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/infiniband/hw/amso1100/c2.c b/drivers/infiniband/hw/amso1100/c2.c index 766a71c..c623e82 100644 --- a/drivers/infiniband/hw/amso1100/c2.c +++ b/drivers/infiniband/hw/amso1100/c2.c @@ -231,6 +231,10 @@ static inline int c2_rx_alloc(struct c2_port *c2_port, struct c2_element *elem) mapaddr = pci_map_single(c2dev->pcidev, skb->data, maplen, PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error(c2dev->pcidev, mapaddr)) { + dev_kfree_skb(skb); + return -ENOMEM; + } /* Set the sk_buff RXP_header to RXP_HRXD_READY */ rxp_hdr = (struct c2_rxp_hdr *) skb->data;