From patchwork Sun Oct 24 16:33:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 265702 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9OH3p2m020572 for ; Sun, 24 Oct 2010 17:03:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758834Ab0JXRDr (ORCPT ); Sun, 24 Oct 2010 13:03:47 -0400 Received: from mx.treblig.org ([80.68.94.177]:58537 "EHLO mx.treblig.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758822Ab0JXRDr (ORCPT ); Sun, 24 Oct 2010 13:03:47 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sun, 24 Oct 2010 17:03:51 +0000 (UTC) X-Greylist: delayed 1836 seconds by postgrey-1.27 at vger.kernel.org; Sun, 24 Oct 2010 13:03:46 EDT Received: from dg by mx.treblig.org with local (Exim 4.69) (envelope-from ) id 1PA3VN-0003Xg-1G; Sun, 24 Oct 2010 17:33:09 +0100 Date: Sun, 24 Oct 2010 17:33:09 +0100 From: "Dr. David Alan Gilbert" To: linux-kernel@vger.kernel.org Cc: linux-media@vger.kernel.org, mchehab@redhat.com Subject: [PATCH] Guard a divide in v4l1 compat layer Message-ID: <20101024163308.GA6612@gallifrey> MIME-Version: 1.0 Content-Disposition: inline X-Chocolate: 70 percent or better cocoa solids preferably X-Operating-System: Linux/2.6.32.20-kvm-i386-20100823 (i686) X-Uptime: 17:22:02 up 60 days, 48 min, 1 user, load average: 0.00, 0.00, 0.00 User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c index 0c2105c..d4ac751 100644 --- a/drivers/media/video/v4l1-compat.c +++ b/drivers/media/video/v4l1-compat.c @@ -645,9 +645,16 @@ static noinline long v4l1_compat_get_picture( goto done; } - pict->depth = ((fmt->fmt.pix.bytesperline << 3) - + (fmt->fmt.pix.width - 1)) - / fmt->fmt.pix.width; + if (fmt->fmt.pix.width) + { + pict->depth = ((fmt->fmt.pix.bytesperline << 3) + + (fmt->fmt.pix.width - 1)) + / fmt->fmt.pix.width; + } else { + err = -EINVAL; + goto done; + } + pict->palette = pixelformat_to_palette( fmt->fmt.pix.pixelformat); done: