From patchwork Wed Aug 7 07:22:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bgottumukkala@emulex.com X-Patchwork-Id: 2839952 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 00B41BF535 for ; Wed, 7 Aug 2013 07:14:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7FAE2012F for ; Wed, 7 Aug 2013 07:14:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 407532017B for ; Wed, 7 Aug 2013 07:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757100Ab3HGHOc (ORCPT ); Wed, 7 Aug 2013 03:14:32 -0400 Received: from cmexedge1.ext.emulex.com ([138.239.224.99]:30326 "EHLO CMEXEDGE1.ext.emulex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756960Ab3HGHOc (ORCPT ); Wed, 7 Aug 2013 03:14:32 -0400 Received: from CMEXHTCAS1.ad.emulex.com (138.239.115.217) by CMEXEDGE1.ext.emulex.com (138.239.224.99) with Microsoft SMTP Server (TLS) id 14.3.146.0; Wed, 7 Aug 2013 00:15:14 -0700 Received: from RoCE-SLESS-DUT.site (10.192.238.42) by smtp.emulex.com (138.239.115.207) with Microsoft SMTP Server id 14.3.146.0; Wed, 7 Aug 2013 00:14:30 -0700 From: To: CC: , Naresh Gottumukkala Subject: [PATCH 3/6] RDMA/ocrdma: Don't allow zero/invalid sgid usage. Date: Wed, 7 Aug 2013 12:52:34 +0530 X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1375860157-10588-1-git-send-email-bgottumukkala@emulex.com> References: <1375860157-10588-1-git-send-email-bgottumukkala@emulex.com> MIME-Version: 1.0 Message-ID: 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, 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 From: Naresh Gottumukkala Dont allow zero/invalid sgid usage. Signed-off-by: Naresh Gottumukkala --- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index 6bbcc78..af01ba2 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c @@ -2124,9 +2124,10 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp, { int status; struct ib_ah_attr *ah_attr = &attrs->ah_attr; - union ib_gid sgid; + union ib_gid sgid, zgid; u32 vlan_id; u8 mac_addr[6]; + if ((ah_attr->ah_flags & IB_AH_GRH) == 0) return -EINVAL; cmd->params.tclass_sq_psn |= @@ -2142,6 +2143,11 @@ static int ocrdma_set_av_params(struct ocrdma_qp *qp, ah_attr->grh.sgid_index, &sgid); if (status) return status; + + memset(&zgid, 0, sizeof(zgid)); + if (!memcmp(&sgid, &zgid, sizeof(zgid))) + return -EINVAL; + qp->sgid_idx = ah_attr->grh.sgid_index; memcpy(&cmd->params.sgid[0], &sgid.raw[0], sizeof(cmd->params.sgid)); ocrdma_resolve_dgid(qp->dev, &ah_attr->grh.dgid, &mac_addr[0]);