Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp51304pxv; Thu, 24 Jun 2021 02:33:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxra2Vcd6Wv7v1zvuoMcWqHd7zym7g0mr0YqsZdIAz6OYD0GQqxNwFsfojcjW/SCItgZA3A X-Received: by 2002:a05:6402:40c4:: with SMTP id z4mr5917724edb.364.1624527210590; Thu, 24 Jun 2021 02:33:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1624527210; cv=pass; d=google.com; s=arc-20160816; b=QzZFueCt9burxA7HonLy5hjVVdsH7OACMqSAzSPs3zgv3CpSs85NquS8henQbt/bHY QurJiZhd0P7HxYgh8DYsmc7Tuw7/SR0I5NMTiXRDcO+gGBQz1iqeJ4kya64Y77DRr9Db MJ6yyPTo/KH1+tUim2aXk+37lIKfcLNYwI3wavUIqlp4825UuCi9J+szUPlXbPF0G1hF uhzOuEDgRvc87IInOjpzqj6nepfbfDNV2DQq5q4utOwr3SoslO+u7e2Z+b1SEtD9Xb10 W92AakVIVs8msfPksgtqnJpDaBDzqkre4HZ3KSMMYZEpIkWS84nIPrPg3XMxJyIGEsbb pccQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=0iGvap/eV/2zN+OduewABmqhwVAmw9j6ZCNs+E9n+7s=; b=IibM+Ug6gKgiXqIq0h/rjCz/ZDgkPPphcUGcZEbZNIHhGn1fyw4+YX7W49d3OvNFOZ upjtvskIfZfoGJ1kSI229fxLJQoFP7edsZiBgwJSYg2N7LXFynKjy1ZhSaXZN5/IL6SV cYDgw/UTk3xrZcG6ppNK03Yg/i73s7QgmGqYLUfhcSiVPow9P+l4ajxw7Sq8AJJpNs3M WZ8J3Qva5/6Q5HH0yV9PUWlzSQQV66+/Wf2S97TmqqJ5I2ZDQxqqwRCJ7+Q6/D/zaOj9 b0QhkKBmB4PW/0hGIQMtT2PVNiweSUnMXSJn0geA1NTCewKW39zI1zeoJO0bgxiQDDNA hDaA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=lahtoruutu header.b=Bwyq8etv; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz1si2405032ejc.257.2021.06.24.02.33.07; Thu, 24 Jun 2021 02:33:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@iki.fi header.s=lahtoruutu header.b=Bwyq8etv; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231949AbhFXJeP (ORCPT + 99 others); Thu, 24 Jun 2021 05:34:15 -0400 Received: from lahtoruutu.iki.fi ([185.185.170.37]:40780 "EHLO lahtoruutu.iki.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230438AbhFXJeO (ORCPT ); Thu, 24 Jun 2021 05:34:14 -0400 Received: from hillosipuli.retiisi.eu (dsl-hkibng32-54fb5d-176.dhcp.inet.fi [84.251.93.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sailus) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 982391B0024A; Thu, 24 Jun 2021 12:31:53 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1624527113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0iGvap/eV/2zN+OduewABmqhwVAmw9j6ZCNs+E9n+7s=; b=Bwyq8etvkB/0uY3kyLMjJ0NwenO7cKiLkoZace9ArWOSysAA4bfxPWS7cbEfI8jucNkdrX 3domcPovaTvxKZGysxvgpgyQdcj2aC2bv6FHRkP2qmG4JHlsswR6Gi43Eer3GA40renpgV FFdUv3KVNSpIczMU5mrOx+lCZUfBE0d0Tp857HYh7Q3mBveImln9KUSbRRCPvYFueFlGY0 /E2RZ7aSDEHDLZ4fel2hfQ++s8Y/m4+bq0HzzTbXnurMA8ElUtiPH8+y9HR494t+eJcQ4E paYzM81mEFtQ2bohdw7tjYWIU46Wy9lq0xUnrtfX1634uPPft+/JfpdfzT/8Wg== Received: from valkosipuli.localdomain (valkosipuli.localdomain [IPv6:fd35:1bc8:1a6:d3d5::80:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by hillosipuli.retiisi.eu (Postfix) with ESMTPS id 45BEB634C87; Thu, 24 Jun 2021 12:31:38 +0300 (EEST) Received: from localhost ([127.0.0.1] helo=valkosipuli.retiisi.eu) by valkosipuli.localdomain with esmtp (Exim 4.92) (envelope-from ) id 1lwLiD-00018j-LB; Thu, 24 Jun 2021 12:31:53 +0300 Date: Thu, 24 Jun 2021 12:31:53 +0300 From: Sakari Ailus To: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [PATCH 3/5] media: v4l2-flash-led-class: drop an useless check Message-ID: <20210624093153.GJ3@valkosipuli.retiisi.eu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1624527113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0iGvap/eV/2zN+OduewABmqhwVAmw9j6ZCNs+E9n+7s=; b=ADnv+RUlGBaMwtBb94n6it4QAk7BC1zxy4gLpiYqYxKoxRYZ97sFroqHlCblk7LiqTvHq1 zs/YeJnQDaZATf7vxOm6rV1oWnV7qSPZLuoqztwUesOUfM0xPht0OwLuMvckO9iv6uNlxq xr8urOWpE1iDytBNR2QkJ9gBaINaoFGO03UWZLVx2ry4hyUNAgfIGopDdQneY7fg1kUUpr lyCT4WgtlR43poAoZT+8PAalqBpe4MhY/zSb2dgAgK+XZcn9dp/8IVvwl0dhrDXdsUAARv 69aeDe0QmM6dopX8mVRUZuPCjT02UIJdplIDaWRmuO9wW3SwxgrdCvnH8Sgy3Q== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=sailus smtp.mailfrom=sakari.ailus@iki.fi ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1624527113; a=rsa-sha256; cv=none; b=an+WbC0hAzt6h4+MOeIXZTnD48xR25ndkJxgHSBgwJKS3NBfOGH5+EdYMHoiahmtIlFpG0 /7F5JKVWPXyRHW/VB5u48s5KCji1bFBbgqiZrurXbohC/eNBriRjMXNGPnFlaHPpsr6FRs rtsa3zqHX1dfIp3xULibuBmtV64MyrcUCTbIDaZpnjwqP1ToUdB5f6VjyFnx5bi7RP40uT fhpqyj3DFBlr+E/9PIbk61JXP5I/swMisr6UvIMbANqkxIxSUSWkBHOo0xOTFMvRLrBIYG tSS9d0Hl8J2DPHjrGuY0vUlg3dWoyy8HU0WnChBGcdDLiIBRjnsR5jwbpYYO/w== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mauro, Could you check if your mail client could be configured not to add junk to To: field? It often leads anything in the Cc: field being dropped. On Mon, Jun 21, 2021 at 01:56:47PM +0200, Mauro Carvalho Chehab wrote: > As pointed by smatch: > drivers/media/v4l2-core/v4l2-flash-led-class.c:264 v4l2_flash_s_ctrl() error: we previously assumed 'fled_cdev' could be null (see line 197) > > It is too late to check if fled_cdev is NULL there. If such check is > needed, it should be, instead, inside v4l2_flash_init(). > > On other words, if v4l2_flash->fled_cdev() is NULL at > v4l2_flash_s_ctrl(), all led_*() function calls inside the function > would try to de-reference a NULL pointer, as the logic won't prevent > it. > > So, remove the useless check. > > Signed-off-by: Mauro Carvalho Chehab > --- > drivers/media/v4l2-core/v4l2-flash-led-class.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c > index 10ddcc48aa17..a1653c635d82 100644 > --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c > +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c > @@ -194,7 +194,7 @@ static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c) > { > struct v4l2_flash *v4l2_flash = v4l2_ctrl_to_v4l2_flash(c); > struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev; > - struct led_classdev *led_cdev = fled_cdev ? &fled_cdev->led_cdev : NULL; > + struct led_classdev *led_cdev = &fled_cdev->led_cdev; fled_cdev may be NULL here. The reason is that some controls are for flash LEDs only but the same sub-device may also control an indicator. This is covered when the controls are created, so that the NULL pointer isn't dereferenced. If you wish the false positive to be addressed while also improving the implementation, that could be done by e.g. splitting the switch into two, the part that needs fled_cdev and another that doesn't. I can send a patch for that. Please also cc me to V4L2 flash class patches. I noticed this one by accident only. > struct v4l2_ctrl **ctrls = v4l2_flash->ctrls; > bool external_strobe; > int ret = 0; -- Kind regards, Sakari Ailus