From patchwork Thu May 6 14:52:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ang Way Chuang X-Patchwork-Id: 97358 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o46EpaqW023027 for ; Thu, 6 May 2010 14:54:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753897Ab0EFOw2 (ORCPT ); Thu, 6 May 2010 10:52:28 -0400 Received: from mail-px0-f174.google.com ([209.85.212.174]:47238 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753789Ab0EFOw1 (ORCPT ); Thu, 6 May 2010 10:52:27 -0400 Received: by pxi5 with SMTP id 5so17849pxi.19 for ; Thu, 06 May 2010 07:52:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=H754hN4bKarhWEZatOdmiko27wwSIAhEpJYSekIQTqw=; b=fgQJX08LlpktbAwzB3yu6rVr+K8DH8mKsFJlYCKIbWu49zqxvFw73sQ+R/6GKAT3sR 7HL3/GfeJznQv6mGLbQLFWq86hgdJX/p87+V+nHaLtvSKAr/AQ79ibLRvQA4hPqesE8m fjj4jH2ZmV7JF3e2xmfZw/UuUZqlHrerv77Ck= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=GrFGjXuncOYy19O+8YdZtHDDOZHNeOqWmnRHQUSda1XHG51fxjIxyEWYdZHhnlKitQ sJrv+m0vT2SwjFh/mfCGWQfyNLumyU2VPaSoIjm7QhpZ2s1WHvRZPRodG+o2lCGSeBwU 7h5VzXpThWEK5lP6CT+NtyXXT3VBVlZo0611U= Received: by 10.115.133.17 with SMTP id k17mr2555086wan.24.1273157547093; Thu, 06 May 2010 07:52:27 -0700 (PDT) Received: from [192.168.1.3] ([118.101.138.189]) by mx.google.com with ESMTPS id b6sm4729176wam.9.2010.05.06.07.52.25 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 06 May 2010 07:52:26 -0700 (PDT) Message-ID: <4BE2D7A6.30201@gmail.com> Date: Thu, 06 May 2010 22:52:22 +0800 From: Ang Way Chuang User-Agent: Thunderbird 2.0.0.24 (X11/20100411) MIME-Version: 1.0 To: linux-media@vger.kernel.org Subject: [PATCH] dvb-core: Fix ULE decapsulation bug when less than 4 bytes of ULE SNDU is packed into the remaining bytes of a MPEG2-TS frame Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 06 May 2010 14:54:12 +0000 (UTC) diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index 441c064..35a4afb 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c @@ -458,8 +458,9 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) "field: %u.\n", priv->ts_count, *from_where); /* Drop partly decoded SNDU, reset state, resync on PUSI. */ - if (priv->ule_skb) { - dev_kfree_skb( priv->ule_skb ); + if (priv->ule_skb || priv->ule_sndu_remain) { + if (priv->ule_skb) + dev_kfree_skb( priv->ule_skb ); dev->stats.rx_errors++; dev->stats.rx_frame_errors++; } @@ -534,6 +535,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) from_where += 2; } + priv->ule_sndu_remain = priv->ule_sndu_len + 2; /* * State of current TS: * ts_remain (remaining bytes in the current TS cell) @@ -543,6 +545,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) */ switch (ts_remain) { case 1: + priv->ule_sndu_remain--; priv->ule_sndu_type = from_where[0] << 8; priv->ule_sndu_type_1 = 1; /* first byte of ule_type is set. */ ts_remain -= 1; from_where += 1; @@ -556,6 +559,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) default: /* complete ULE header is present in current TS. */ /* Extract ULE type field. */ if (priv->ule_sndu_type_1) { + priv->ule_sndu_type_1 = 0; priv->ule_sndu_type |= from_where[0]; from_where += 1; /* points to payload start. */ ts_remain -= 1;