From patchwork Mon Jul 11 01:58:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 962992 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6B1xmVq015878 for ; Mon, 11 Jul 2011 01:59:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756568Ab1GKB7p (ORCPT ); Sun, 10 Jul 2011 21:59:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62356 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756166Ab1GKB7n (ORCPT ); Sun, 10 Jul 2011 21:59:43 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6B1xgwg023461 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 10 Jul 2011 21:59:42 -0400 Received: from pedra (vpn-225-29.phx2.redhat.com [10.3.225.29]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p6B1xKKZ030664 for ; Sun, 10 Jul 2011 21:59:42 -0400 Date: Sun, 10 Jul 2011 22:58:55 -0300 From: Mauro Carvalho Chehab Cc: Linux Media Mailing List Subject: [PATCH 07/21] [media] drxk: Avoid OOPSes if firmware is corrupted Message-ID: <20110710225855.3d7534e8@pedra> In-Reply-To: References: Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 To: unlisted-recipients:; (no To-header on input) 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.6 (demeter1.kernel.org [140.211.167.41]); Mon, 11 Jul 2011 01:59:48 +0000 (UTC) Don't read paste the buffer, if the firmware is corrupted. Instead, print an error message. Signed-off-by: Mauro Carvalho Chehab diff --git a/drivers/media/dvb/frontends/drxk_hard.c b/drivers/media/dvb/frontends/drxk_hard.c index c4b35a5..89db378 100644 --- a/drivers/media/dvb/frontends/drxk_hard.c +++ b/drivers/media/dvb/frontends/drxk_hard.c @@ -1388,6 +1388,12 @@ static int DownloadMicrocode(struct drxk_state *state, BlockCRC = (pSrc[0] << 8) | pSrc[1]; pSrc += sizeof(u16); offset += sizeof(u16); + + if (offset + BlockSize > Length) { + printk(KERN_ERR "drxk: Firmware is corrupted.\n"); + return -EINVAL; + } + status = write_block(state, Address, BlockSize, pSrc); if (status < 0) break;