From patchwork Sun Oct 23 10:22:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 9391055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F0E04607FF for ; Sun, 23 Oct 2016 10:22:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E381028CE1 for ; Sun, 23 Oct 2016 10:22:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D46F528CE3; Sun, 23 Oct 2016 10:22:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85C0A28CE1 for ; Sun, 23 Oct 2016 10:22:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753156AbcJWKWU (ORCPT ); Sun, 23 Oct 2016 06:22:20 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:51190 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752092AbcJWKWR (ORCPT ); Sun, 23 Oct 2016 06:22:17 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 6F27582331; Sun, 23 Oct 2016 12:22:14 +0200 (CEST) Date: Sun, 23 Oct 2016 12:22:13 +0200 From: Pavel Machek To: Ivaylo Dimitrov Cc: sakari.ailus@iki.fi, sre@kernel.org, pali.rohar@gmail.com, linux-media@vger.kernel.org, galak@codeaurora.org, mchehab@osg.samsung.com, linux-kernel@vger.kernel.org Subject: v4.9-rc1: smiapp divides by zero Message-ID: <20161023102213.GA13705@amd> References: <1465659593-16858-1-git-send-email-ivo.g.dimitrov.75@gmail.com> <20161023073322.GA3523@amd> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161023073322.GA3523@amd> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi! I tried to update camera code on n900 to v4.9-rc1, and I'm getting some divide by zero, that eventually cascades into fcam-dev not working. mul is zero in my testing, resulting in divide by zero. (Note that this is going from my patched camera-v4.8 tree to camera-v4.9 tree.) Best regards, Pavel diff --git a/drivers/media/i2c/smiapp-pll.c b/drivers/media/i2c/smiapp-pll.c index 5ad1edb..e0a6edd 100644 --- a/drivers/media/i2c/smiapp-pll.c +++ b/drivers/media/i2c/smiapp-pll.c @@ -16,6 +16,8 @@ * General Public License for more details. */ +#define DEBUG + #include #include #include @@ -457,6 +459,10 @@ int smiapp_pll_calculate(struct device *dev, i = gcd(pll->pll_op_clk_freq_hz, pll->ext_clk_freq_hz); mul = div_u64(pll->pll_op_clk_freq_hz, i); div = pll->ext_clk_freq_hz / i; + if (!mul) { + dev_err(dev, "forcing mul to 1\n"); + mul = 1; + } dev_dbg(dev, "mul %u / div %u\n", mul, div); min_pre_pll_clk_div =