From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCB4EC433EF for ; Wed, 4 May 2022 06:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345090AbiEDG7l (ORCPT ); Wed, 4 May 2022 02:59:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345078AbiEDG7i (ORCPT ); Wed, 4 May 2022 02:59:38 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B90D9F52 for ; Tue, 3 May 2022 23:56:03 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2DC1A1042; Tue, 3 May 2022 23:56:03 -0700 (PDT) Received: from e120937-lin (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 570123FA49; Tue, 3 May 2022 23:56:02 -0700 (PDT) Date: Wed, 4 May 2022 07:55:56 +0100 From: Cristian Marussi To: Dan Carpenter Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, kernel test robot Subject: Re: [PATCH] firmware: arm_scmi: Fix late checks on pointer dereference Message-ID: References: <20220503121047.3590340-1-cristian.marussi@arm.com> <20220504064436.GJ4031@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220504064436.GJ4031@kadam> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 04, 2022 at 09:44:36AM +0300, Dan Carpenter wrote: > On Tue, May 03, 2022 at 01:10:47PM +0100, Cristian Marussi wrote: > > A few dereferences could happen before the iterator pointer argument was > > checked for NULL, causing the following smatch warnings: > > > > drivers/firmware/arm_scmi/driver.c:1214 scmi_iterator_run() warn: variable > > dereferenced before check 'i' (see line 1210) > > > > Fix by moving the checks early and dropping some unneeded local references. > > > > No functional change. > Hi Dan, thanks for you feedback first of all. > If there is no chance these can be NULL then a different option is to > just delete the NULL checks. Indeed, I think I kept only the checks on iter param that can possibly be NULL if the caller messes up the usage of this iterator interface (or if the internals are messed up by future developments...just to play on the safe side). Thanks, Cristian