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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD346C433EF for ; Mon, 25 Oct 2021 16:48:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8ED25601FF for ; Mon, 25 Oct 2021 16:48:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234071AbhJYQun (ORCPT ); Mon, 25 Oct 2021 12:50:43 -0400 Received: from mga14.intel.com ([192.55.52.115]:50665 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233257AbhJYQum (ORCPT ); Mon, 25 Oct 2021 12:50:42 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10148"; a="229970358" X-IronPort-AV: E=Sophos;i="5.87,181,1631602800"; d="scan'208";a="229970358" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2021 09:41:18 -0700 X-IronPort-AV: E=Sophos;i="5.87,181,1631602800"; d="scan'208";a="664138931" Received: from smile.fi.intel.com ([10.237.72.184]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2021 09:41:16 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1mf31s-000v5h-2Y; Mon, 25 Oct 2021 19:40:56 +0300 Date: Mon, 25 Oct 2021 19:40:55 +0300 From: "andriy.shevchenko@linux.intel.com" To: YE Chengfeng , Sakari Ailus Cc: "heikki.krogerus@linux.intel.com" , "linux-kernel@vger.kernel.org" Subject: Re: suspected null-pointer-reference problem for to_swnode Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 25, 2021 at 02:03:51PM +0000, YE Chengfeng wrote: > Hi, > > https://github.com/torvalds/linux/blob/master/drivers/base/swnode.c#L405 > > We notice that the return pointer of to_swnode is null check in some case, while in some case is not. For example, at line 416, the return pointer is null-check, but in line 405 is not. We want to know whether it would be a potential null pointer dereference problem, in the case that null-check is missing. > > This problem is detected by our experimental static analysis tool, we are not familiar with the source code and it could just be a false positive. We send this email in case this is a real problem. Would you like to spare some time to have a look at it? Thank you for the interest to our code! Line #405 refers to software node operations and it means it won't be ever called if there is no swnode behind it, means it's backed with properties. If you think it will be a NULL pointer there, please describe in detail (with a traceback included) when and how it happens, because such bugs are serious. Line #416 refers to the same stage when options are defined and we know we have been called against swnode. Seems to me like a dead code brought from day 1 by the commit bc0500c1e43d ("device property: Add fwnode_get_name for returning the name of a node"). Sakari? -- With Best Regards, Andy Shevchenko