From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753289AbbIQFQz (ORCPT ); Thu, 17 Sep 2015 01:16:55 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:54359 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752145AbbIQFQx (ORCPT ); Thu, 17 Sep 2015 01:16:53 -0400 Date: Thu, 17 Sep 2015 07:16:44 +0200 From: Pavel Machek To: Pali =?iso-8859-1?Q?Roh=E1r?= Cc: Peter Teoh , Tomi Valkeinen , Jean-Christophe Plagniol-Villard , Jyri Sarha , omap , linux-fbdev@vger.kernel.org, LKML , Sebastian Reichel , Aaro Koskinen , Tony Lindgren , Nishanth Menon Subject: Re: omapdss: Division by zero in kernel Message-ID: <20150917051644.GA6665@amd> References: <201507241803.42891@pali> <20150819081139.GB15712@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150819081139.GB15712@pali> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > if (image->depth == 1) { > > if (p->fix.visual == FB_VISUAL_TRUECOLOR || > > p->fix.visual == FB_VISUAL_DIRECTCOLOR) { > > fgcolor = ((u32*)(p->pseudo_palette))[image->fg_color]; > > bgcolor = ((u32*)(p->pseudo_palette))[image->bg_color]; > > } else { > > fgcolor = image->fg_color; > > bgcolor = image->bg_color; > > } > > > > if (32 % bpp == 0 && !start_index && !pitch_index && > > ((width & (32/bpp-1)) == 0) && > > bpp >= 8 && bpp <= 32) > > fast_imageblit(image, p, dst1, fgcolor, bgcolor); > > else > > slow_imageblit(image, p, dst1, fgcolor, bgcolor, > > start_index, pitch_index); > > } else > > color_imageblit(image, p, dst1, start_index, pitch_i > > > > > > Notice that bpp is not checked for zero, and thus bpp==0 is totally > > feasible? resulting in 32/bpp crashing the kernel? > > > > Hm... this could really be a problem! But how to patch it? Which branch > should be called (fast_ or slow_ function) if bpp is zero? > > And is there some way to force kernel to dump backtrace into dmesg when > division by zero occur? You can do WARN_ON(bpp==1) ... and should probably return in that case. Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html