From patchwork Wed Jan 28 23:50:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Dolca X-Patchwork-Id: 5733301 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 67AF19F36E for ; Thu, 29 Jan 2015 01:28:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A428A20149 for ; Thu, 29 Jan 2015 01:28:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2460C201DD for ; Thu, 29 Jan 2015 01:27:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755275AbbA2B1m (ORCPT ); Wed, 28 Jan 2015 20:27:42 -0500 Received: from mga03.intel.com ([134.134.136.65]:60190 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755260AbbA2B1j (ORCPT ); Wed, 28 Jan 2015 20:27:39 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 28 Jan 2015 15:46:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,483,1418112000"; d="scan'208";a="644203634" Received: from rdolca-desk.ger.corp.intel.com (HELO rdolca-desk.rb.intel.com) ([10.237.104.134]) by orsmga001.jf.intel.com with ESMTP; 28 Jan 2015 15:50:54 -0800 From: Robert Dolca To: linux-nfc@lists.01.org, Lauro Ramos Venancio , Aloisio Almeida Jr , Samuel Ortiz Cc: linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, "David S. Miller" , Berg Johannes , Clement Perrochaud , Robert Dolca Subject: [RFC] NFC: PN544: Supply the right length to skb_trim Date: Thu, 29 Jan 2015 01:50:46 +0200 Message-Id: <1422489046-6087-1-git-send-email-robert.dolca@intel.com> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@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 The 2nd parameter of skb_trim is the new length of the skb. pn544_hci_i2c_remove_len_crc used the tailroom for the 2nd parameter so the new length was 2 no metter how big the skb was. Now the length is (skb->len - PN544_I2C_FRAME_TAILROOM) Signed-off-by: Robert Dolca --- drivers/nfc/pn544/i2c.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c index 58b9029..42e7b26 100644 --- a/drivers/nfc/pn544/i2c.c +++ b/drivers/nfc/pn544/i2c.c @@ -297,7 +297,7 @@ static void pn544_hci_i2c_add_len_crc(struct sk_buff *skb) static void pn544_hci_i2c_remove_len_crc(struct sk_buff *skb) { skb_pull(skb, PN544_I2C_FRAME_HEADROOM); - skb_trim(skb, PN544_I2C_FRAME_TAILROOM); + skb_trim(skb, skb->len - PN544_I2C_FRAME_TAILROOM); } /* @@ -411,8 +411,7 @@ static int pn544_hci_i2c_read(struct pn544_i2c_phy *phy, struct sk_buff **skb) goto flush; } - skb_pull(*skb, 1); - skb_trim(*skb, (*skb)->len - 2); + pn544_hci_i2c_remove_len_crc(*skb); usleep_range(3000, 6000);