From patchwork Thu Jul 5 21:17:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland Dreier X-Patchwork-Id: 1162261 X-Patchwork-Delegate: roland@digitalvampire.org Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 686A6DFB7C for ; Thu, 5 Jul 2012 21:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751138Ab2GEVRt (ORCPT ); Thu, 5 Jul 2012 17:17:49 -0400 Received: from na3sys010aog114.obsmtp.com ([74.125.245.96]:35320 "HELO na3sys010aog114.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751025Ab2GEVRt (ORCPT ); Thu, 5 Jul 2012 17:17:49 -0400 Received: from mail-gg0-f179.google.com ([209.85.161.179]) (using TLSv1) by na3sys010aob114.postini.com ([74.125.244.12]) with SMTP ID DSNKT/YEfPosr/XUYiF+6W8Xf4eVSr1/rypG@postini.com; Thu, 05 Jul 2012 14:17:49 PDT Received: by ggnk3 with SMTP id k3so7750793ggn.38 for ; Thu, 05 Jul 2012 14:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=EC1GqOINWWNRDFDHdo2x0ww0dc1xxoQsChmoRx07Xow=; b=ZLlEaC9HL+cusklGFDqMjFC5YeNOYddVEVNP6Ii2EfecZLay5Pui9CEBE4pMt2u6dQ I/VQ/vliQoXdLidplk+Qe+PHGPs8Fdj3HIQnUD8tXz6ji7zADTMcKko2hlermWJUiiXC rs5ZKL+KCa99gHkrnvlOW1OqyaM86P/taq7/Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=EC1GqOINWWNRDFDHdo2x0ww0dc1xxoQsChmoRx07Xow=; b=hMpmi5D/zYhkttvtiYXFFGlRauGUbiA6WkB1zf9lX39eohpeZ/rH197P6ygusWmG0p mOJQFFp+2klf4qt1viLrln8WZVXDEKWExLGaV/gjY8O44L/5Bc7gfs95YqqS7hnlWGJJ 5sVnJX51fwUB9SA6FDefrpz+t0ttA41bUPxbQjK2THcchliLEVQK5uRn0lniAI/ab/Rd A7Ve8GaZg9q0fj4Q5xwbrNBFt8efDFRXYw0FsdErCFkKKhpbQlHfw3svw10lFAE4ddLH nfgQbGc+BmL44O6BpRwHiJg9nzJcIepDbTrBV6ToByAEkJFm7ZTulno12Va813XL/m1r TcXA== Received: by 10.68.240.73 with SMTP id vy9mr30462498pbc.102.1341523067716; Thu, 05 Jul 2012 14:17:47 -0700 (PDT) Received: from roland-t410s.purestorage.com ([216.200.155.2]) by mx.google.com with ESMTPS id ru4sm20414703pbc.66.2012.07.05.14.17.46 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 14:17:47 -0700 (PDT) From: Roland Dreier To: Steve Wise Cc: linux-rdma@vger.kernel.org Subject: [PATCH] RDMA/cxgb4: Fix endianness of addition to mpa->private_data_size Date: Thu, 5 Jul 2012 14:17:43 -0700 Message-Id: <1341523063-7747-1-git-send-email-roland@kernel.org> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQlf//uXuhDj03wy4X413CwSw91GQDhp+En8Ic/tfPVc1WW0a32TtrA3V0A/Gy/Ssr8ISzIF Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Roland Dreier sparse correctly warns that if mpa->private_data_size is __be16, then doing += on it is wrong, even if we do += htons() -- on a little endian system, carries will go the wrong way. Fix this up by doing the addition in native byte order. Acked-by: Steve Wise --- Looks pretty clear to me -- I assume there's no problem merging this? drivers/infiniband/hw/cxgb4/cm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index b18870c..51f4206 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c @@ -548,8 +548,8 @@ static void send_mpa_req(struct c4iw_ep *ep, struct sk_buff *skb, } if (mpa_rev_to_use == 2) { - mpa->private_data_size += - htons(sizeof(struct mpa_v2_conn_params)); + mpa->private_data_size = htons(ntohs(mpa->private_data_size) + + sizeof (struct mpa_v2_conn_params)); mpa_v2_params.ird = htons((u16)ep->ird); mpa_v2_params.ord = htons((u16)ep->ord); @@ -635,8 +635,8 @@ static int send_mpa_reject(struct c4iw_ep *ep, const void *pdata, u8 plen) if (ep->mpa_attr.version == 2 && ep->mpa_attr.enhanced_rdma_conn) { mpa->flags |= MPA_ENHANCED_RDMA_CONN; - mpa->private_data_size += - htons(sizeof(struct mpa_v2_conn_params)); + mpa->private_data_size = htons(ntohs(mpa->private_data_size) + + sizeof (struct mpa_v2_conn_params)); mpa_v2_params.ird = htons(((u16)ep->ird) | (peer2peer ? MPA_V2_PEER2PEER_MODEL : 0)); @@ -715,8 +715,8 @@ static int send_mpa_reply(struct c4iw_ep *ep, const void *pdata, u8 plen) if (ep->mpa_attr.version == 2 && ep->mpa_attr.enhanced_rdma_conn) { mpa->flags |= MPA_ENHANCED_RDMA_CONN; - mpa->private_data_size += - htons(sizeof(struct mpa_v2_conn_params)); + mpa->private_data_size = htons(ntohs(mpa->private_data_size) + + sizeof (struct mpa_v2_conn_params)); mpa_v2_params.ird = htons((u16)ep->ird); mpa_v2_params.ord = htons((u16)ep->ord); if (peer2peer && (ep->mpa_attr.p2p_type !=