From patchwork Tue Dec 16 14:55:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 5500971 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8734D9F326 for ; Tue, 16 Dec 2014 14:56:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E70120A1C for ; Tue, 16 Dec 2014 14:56:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 708F620A1E for ; Tue, 16 Dec 2014 14:56:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750968AbaLPO4A (ORCPT ); Tue, 16 Dec 2014 09:56:00 -0500 Received: from mail-wi0-f172.google.com ([209.85.212.172]:56589 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750922AbaLPO4A convert rfc822-to-8bit (ORCPT ); Tue, 16 Dec 2014 09:56:00 -0500 Received: by mail-wi0-f172.google.com with SMTP id n3so12544083wiv.5 for ; Tue, 16 Dec 2014 06:55:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc :content-type:content-transfer-encoding; bh=/LuRXuAiYtaPnOVrGKcwRT4aCJ+JFs700FwyuDZZFy8=; b=Z6o8fseivCPN2FigAxaOg6wmR17DCJwcxuqDKS6KaoJt3Y4JCpuYA/8zaxrDgPdnqh QuSbvYYNq2u3OwRn4wrDYknIhF/u2304HpEMcN/vA1txgzN+JKmGCiwqxXmE4Bq/Wtak Mjqq1iCJV+z4iRrPcuAVW0L6KJZaHllcyFZhX+c19WEVWUay/tvlWCLkRCzF9wd3fPKn iEb+mrVZGoiQ98jzHwMUED0Zfc4PDNbX3XUvNiFrlJlinoEigyx7q3W6Krc2LUiEfK4L ImXX/PVTNG+vXZcJJK4P6Gl3IhnjO7f7Tcdh4Rjvor+fzTW5gTsfOMfDIapPkykj9bqo Zf8g== X-Gm-Message-State: ALoCoQkGAGs4s8mMF+f4RClbD5DVgiaG94ZktHRJ0hLwRGgXRxmCnUvQbUmQHEgLbEAC3ln96+6/ X-Received: by 10.194.172.72 with SMTP id ba8mr63432496wjc.13.1418741758802; Tue, 16 Dec 2014 06:55:58 -0800 (PST) MIME-Version: 1.0 Received: by 10.27.12.32 with HTTP; Tue, 16 Dec 2014 06:55:38 -0800 (PST) From: Jinpu Wang Date: Tue, 16 Dec 2014 15:55:38 +0100 Message-ID: Subject: [PATCH]RDMA/cma: fix first byte overwritten for AF_IB To: Roland Dreier Cc: "linux-rdma@vger.kernel.org" , Fabian Holler 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=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 commit 56e620c453f2588cfc9898a41b110477f6417a5d Author: Jack Wang Date: Tue Dec 16 15:44:17 2014 +0100 RDMA/cma: fix first byte overwritten for AF_IB If user attach private data for AF_IB, the first byte will be overwritten, because we always set the cma version no matter family is AF_IB, so move the version set inside if condition. Reported-by: Fabian Holler Signed-off-by: Jack Wang @@ -2632,6 +2632,7 @@ static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv) } else if (cma_family(id_priv) == AF_INET6) { struct sockaddr_in6 *src6, *dst6; + cma_hdr->cma_version = CMA_VERSION; src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv); dst6 = (struct sockaddr_in6 *) cma_dst_addr(id_priv); diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index d570030..22a22e2 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -2618,10 +2618,10 @@ static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv) struct cma_hdr *cma_hdr; cma_hdr = hdr; - cma_hdr->cma_version = CMA_VERSION; if (cma_family(id_priv) == AF_INET) { struct sockaddr_in *src4, *dst4; + cma_hdr->cma_version = CMA_VERSION; src4 = (struct sockaddr_in *) cma_src_addr(id_priv); dst4 = (struct sockaddr_in *) cma_dst_addr(id_priv);