Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2858234imm; Mon, 10 Sep 2018 07:29:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYZmhss5WSAKIWag7DTHMZb4KCkUpK5lQBMphbqW5t6Rx+/cN3Ufmy8lukOvkVoRDtI4C91 X-Received: by 2002:a17:902:7798:: with SMTP id o24-v6mr22141198pll.93.1536589781947; Mon, 10 Sep 2018 07:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536589781; cv=none; d=google.com; s=arc-20160816; b=I4G0HR7x6mmwf8I+51ZW1MKCrvmwqc12WqacepoBWGY6YTKjTJHZZbvV5Vy+T5joQv vE4QK1XDsRAFzHJxiFcVw2w7eyoIXeIR9SlyJ6R9bC5FE+Y6BY4TRAC7WSbb1Age+wTU j6f7DGpfSphKg/BFwhtg4q8oOY4yXKbEcqMx4qzrgAgzHvDPVmwDlS4u+4HdzrEVuRNa vLmnBD+edOXSYp0XC8swrNR0deLkNYU7lHqEgtq3u89DOAe+PV7nuJdyuw2bTF5w8sSw 1v89tw+EHN8NsXVfbWCfaYswFp6s0XIu8x8GRee2qMrWaR8RXu6L2TlPRUbkhWPtmaAa tiJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:organization:message-id:date:subject:cc:to :from:dkim-signature; bh=psqt5yjS7jNGomJUzf1Ebx7BnBOuiS8vtd5wIsuFCVc=; b=LAVsnRc5Jvm+TdSYYhHU9KAQUH4ilD1GMuT/GkEjN1S/Zixy/lFZ8SOGmS7j4b4jTT /JWSjKxjFNXy7O6P70PnY97cKvgfe3X7sVtFq0dDPJKj5YiY0lnH7aD8Bqu3oNg101k/ uyDo5dXe5j2KLQjKBfcbOswHrrmv877G0P2kLH0Jtyz6j8ZQTmstCsyx7RTKsCyYD8JL Rxj3h3QiFI2tmJoI1Di2X2Ubs0aN4Rjolbpn3lk6ghrS224Q9MA8TFkgzfgPC+xLODB4 JKx5GQwwC0dbcVU2s1qb9e8VYsBs9ckeXdCA2gPl4I5kL5hDwCGxYRK0nF4tFnVe1V8h 0peA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=sv1wMdV6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7-v6si17610997pgi.261.2018.09.10.07.29.25; Mon, 10 Sep 2018 07:29:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=sv1wMdV6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728541AbeIJTWY (ORCPT + 99 others); Mon, 10 Sep 2018 15:22:24 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:54288 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728187AbeIJTWX (ORCPT ); Mon, 10 Sep 2018 15:22:23 -0400 Received: from avalon.localnet (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 928EF57; Mon, 10 Sep 2018 16:28:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1536589681; bh=wSXNFler1XIm9xK9NCdFNHWXd3+aJKiN5nVgscPQWDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sv1wMdV6Re3JO8Z+o8kXAxi0GGStvtRs+v9QqGsLTLHuxrDBitMgcN2fowtso/u3R lQfKW7G+gN/cx5HX3QebmdEkH51oMBq2wwMlvTs6hR7sy04R6JR5zCZj3xbHjPHZNP D/C5ixKzkfRNV7Twwy4E7bnD/9AlRb0DUg3ZZOG8= From: Laurent Pinchart To: Maxime Ripard Cc: Kishon Vijay Abraham I , Boris Brezillon , Thomas Petazzoni , linux-media@vger.kernel.org, Archit Taneja , Andrzej Hajda , Chen-Yu Tsai , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Krzysztof Witos , Rafal Ciepiela Subject: Re: [PATCH 04/10] phy: dphy: Add configuration helpers Date: Mon, 10 Sep 2018 17:28:11 +0300 Message-ID: <3954754.hq6Pmoh9iE@avalon> Organization: Ideas on Board Oy In-Reply-To: <20180910141603.gnwpkmemevaxbi7b@flea> References: <1923627.Ifno3EcWVN@avalon> <20180910141603.gnwpkmemevaxbi7b@flea> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Maxime, On Monday, 10 September 2018 17:16:03 EEST Maxime Ripard wrote: > On Fri, Sep 07, 2018 at 05:26:29PM +0300, Laurent Pinchart wrote: > >>>> + */ > >>>> +int phy_mipi_dphy_get_default_config(unsigned long pixel_clock, > >>>> + unsigned int bpp, > >>>> + unsigned int lanes, > >>>> + struct phy_configure_opts_mipi_dphy *cfg) > >>>> +{ > >>>> + unsigned long hs_clk_rate; > >>>> + unsigned long ui; > >>>> + > >>>> + if (!cfg) > >>>> + return -EINVAL; > >>> > >>> Should we really expect cfg to be NULL ? > >> > >> It avoids a kernel panic and it's not in a hot patch, so I'd say yes? > > > > A few line below you divide by the lanes parameter without checking > > whether it is equal to 0 first, which would also cause issues. > > You say that like it would be a bad thing to test for this. > > > I believe that invalid values in input parameters should only be handled > > explicitly when considered acceptable for the caller to pass such values. > > In this case a NULL cfg pointer is a bug in the caller, which would get > > noticed during development if the kernel panics. > > In the common case, yes. In the case where that pointer is actually > being lost by the caller somewhere down the line and you have to wait > for a while before it happens, then having the driver inoperant > instead of just having a panic seems like the right thing to do. But why would it happen in the first place ? Why would the pointer be more likely here to be NULL than to contain, for instance, an uninitialized value, which we don't guard against ? -- Regards, Laurent Pinchart