Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4887064ybe; Mon, 16 Sep 2019 21:52:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbUzzuf90zLogsQSOr8wgKnhJ8SV60AYXIHTqtOi1xTMSdJp5jwPnnIjvHXozCCcuBBGgR X-Received: by 2002:a17:906:4a5a:: with SMTP id a26mr3111690ejv.154.1568695970265; Mon, 16 Sep 2019 21:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568695970; cv=none; d=google.com; s=arc-20160816; b=vZuP39AtZPFo3oUrneRkUfItBdokqVkmkmpOOctywPHtLcDPPR/XJdYJTZmvqOwwJ2 l0AKgIE43SiCdx/fhhDSvptvxd+6yhyzCEXn0Nh+T1u9PGqbiWOhjSyjD3oo2RMo8Dfg x1YY4iDEK/wdwwveYUj4uTjFNEVReqVckLwVPUmtv9MSjSFFPtq6puPIWPHxmrOfdWWI +VZOlfZPCaa33khG2lczjpHLNh5Q3O1NTYJmA5wICFUiaYyFWWLmvgUXUBpbQdAMvQ/K N3TIxUL8y1Wex5CroMmyccP0+zeL7XSn+y0jaB7uOgKCrrVjCJQObna4TaesjahZ7HXH lIrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=htUaItMPM0GtbdbehMW31ER9lubAuw4eWSuxXjlcMXI=; b=gJwDImaHU81sYWhub20FiDwxLsaIt4Lsr4DdlSrYeKyTkUXogn+vxFFwj1jED2Mnwi KMRazWrx4wkuX6cOEuG9sSvx2qhKUDuogPFC92kM3cAt3RoaAJDXCv542j2CPrCiJs3h 9I2upB66WwUhOXH5aUwyesTivbW59XMlh5m8COqlG6HXJidQGr2gK2/OaqEaC/Xm7ai8 QgWR0DuxgSHdCJbx3GqRtGkp2rG3aT+PazXiE+/T+sDmPN7dfkL/UD7YyxyxNMd5lcz2 9WAUe8sQ8+i+1iMvsV7UADWz73NrEe++iFuLvr3ly7knOcYXPyo3dvnwprZ5Jy4j9WV6 4+OQ== ARC-Authentication-Results: i=1; mx.google.com; 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 v53si721587edc.378.2019.09.16.21.52.26; Mon, 16 Sep 2019 21:52:50 -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; 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 S2391026AbfIPTYg (ORCPT + 99 others); Mon, 16 Sep 2019 15:24:36 -0400 Received: from smtp11.smtpout.orange.fr ([80.12.242.133]:39713 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388253AbfIPTYf (ORCPT ); Mon, 16 Sep 2019 15:24:35 -0400 Received: from [192.168.1.41] ([90.126.97.183]) by mwinf5d90 with ME id 2KQU210063xPcdm03KQWVm; Mon, 16 Sep 2019 21:24:33 +0200 X-ME-Helo: [192.168.1.41] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 16 Sep 2019 21:24:33 +0200 X-ME-IP: 90.126.97.183 Subject: Re: [PATCH] media: v4l: cadence: Fix how unsued lanes are handled in 'csi2rx_start()' To: Dan Carpenter , Maxime Ripard Cc: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <20190912204450.17625-1-christophe.jaillet@wanadoo.fr> <20190913075709.t35ggip624tybd6l@localhost.localdomain> <20190916062846.GD18977@kadam> From: Christophe JAILLET Message-ID: Date: Mon, 16 Sep 2019 21:24:26 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20190916062846.GD18977@kadam> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: fr Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 16/09/2019 à 08:28, Dan Carpenter a écrit : > On Fri, Sep 13, 2019 at 09:57:09AM +0200, Maxime Ripard wrote: >> Hi Christophe, >> >> On Thu, Sep 12, 2019 at 10:44:50PM +0200, Christophe JAILLET wrote: >>> The 2nd parameter of 'find_first_zero_bit()' is a number of bits, not of >>> bytes. So use 'BITS_PER_LONG' instead of 'sizeof(lanes_used)'. >>> >>> Fixes: 1fc3b37f34f6 ("media: v4l: cadence: Add Cadence MIPI-CSI2 RX driver") >>> Signed-off-by: Christophe JAILLET >>> --- >>> This patch is purely speculative. Using BITS_PER_LONG looks logical to me, >>> but I'm not 100% sure that it is what is expected here. 'csi2rx->max_lanes' >>> could also be a good candidate. >> Yeah, csi2rx->max_lanes would make more sense in that context. Could >> you resend a new version? > This is sort of unrelated, but for Smatch purposes the csi2rx->max_lanes > comes from the firmware in csi2rx_parse_dt() and it could be any u8 > value. Hi Dan, not sure to follow you. csi2rx_probe()   --> csi2rx_get_resources()      -->  ...           dev_cfg = readl(csi2rx->base + CSI2RX_DEVICE_CFG_REG);           ...           csi2rx->max_lanes = dev_cfg & 7;           if (csi2rx->max_lanes > CSI2RX_LANES_MAX) {              dev_err(&pdev->dev, "Invalid number of lanes: %u\n",                      csi2rx->max_lanes);              return -EINVAL;           } So I guess, that we can trust max_lanes because of the 'if (... > CSI2RX_LANES_MAX)' check. Did I miss something? > I sort of wish that people would write code which was known to be > correct just from reading the kernel code, without looking at the > firmware... I guess I could mark v4l2_fwnode_endpoint_parse() as always > giving us valid data, but that still wouldn't tell us what the valid > data is. It's hard to know the right answer from a static analysis > point of view. > > regards, > dan carpenter > >