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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D66DFC4345F for ; Tue, 16 Apr 2024 19:02:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E551112DDF; Tue, 16 Apr 2024 19:02:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="ifWzy08O"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4FA04112DEA; Tue, 16 Apr 2024 19:02:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713294131; x=1744830131; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=cWgfFbkRRGPeHH51a6cCpYsUxCzyFOtg5Ia+0xVpfX0=; b=ifWzy08OLBSsp+ml0IRF07sRjiSBPFvgYgtQOjuQkKYFdxL0zFMmqUC+ CiySaSZBU+bcLzM9V4aqAp40VskbXQnmYQKsOthzV7hqWh83VMo4R2DOH pLo8rouL6Ae+6vEoVutegpgIoNJY1HZWp1vQlrhPdqXEiFZ7ZKU/DrE+L 2nNH8lcE8LI8PfaTfE0hoazvhUSffnWceE6rMQyroXqEjboA0IK8CkSJ2 dkKFDopwcbHlgUkpeu/r+oH7IGOv/Ter2LouMmkeX4OwutUhtaf/ydp3v dsAI7lqH65fBt3rLGt4LvlLu8jRFLYHnG9AoecGUim/S7Pu+FWc5QkbLN Q==; X-CSE-ConnectionGUID: l11c/pwnSBGbPomu8DMT9w== X-CSE-MsgGUID: chS+QOhvQFOlGW/wetf3Cg== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="12535747" X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="12535747" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:02:11 -0700 X-CSE-ConnectionGUID: ft6I1Z/xR1Slpe9WbxVbwg== X-CSE-MsgGUID: eetmvu/LTHes6YDuDm5Zww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,206,1708416000"; d="scan'208";a="59794531" Received: from orsosgc001.jf.intel.com (HELO orsosgc001.intel.com) ([10.165.21.138]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 12:02:11 -0700 Date: Tue, 16 Apr 2024 12:02:10 -0700 Message-ID: <85jzkxcerx.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Rodrigo Vivi Cc: intel-gfx@lists.freedesktop.org, Badal Nilawar , Andi Shyti , Ville =?ISO-8859-1?Q?Syrj=E4l=E4?= , linux-hwmon@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: Re: [PATCH v2] drm/i915/hwmon: Get rid of devm In-Reply-To: References: <20240415223612.738535-1-ashutosh.dixit@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-redhat-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Tue, 16 Apr 2024 11:55:20 -0700, Rodrigo Vivi wrote: > Hi Rodrigo, > > @@ -849,5 +849,26 @@ void i915_hwmon_register(struct drm_i915_private *i915) > > > > void i915_hwmon_unregister(struct drm_i915_private *i915) > > { > > - fetch_and_zero(&i915->hwmon); > > + struct i915_hwmon *hwmon = fetch_and_zero(&i915->hwmon); > > + struct hwm_drvdata *ddat = &hwmon->ddat; > > + struct intel_gt *gt; > > + int i; > > + > > + if (!hwmon) > > + return; > > "that's too late", we are going to hear from static analyzer tools. > > beter to move ddat = &hwmon->ddat; after this return. Yeah, I worried a lot about it :/ But then finally decided (and verified) that we are never actually dereferencing the (possibly NULL) pointer. But not sure about static analyzer tools, maybe you are right, I'll move it. > with that, > > Reviewed-by: Rodrigo Vivi Thanks a lot :) Ashutosh > > > + > > + for_each_gt(gt, i915, i) { > > + struct hwm_drvdata *ddat_gt = hwmon->ddat_gt + i; > > + > > + if (ddat_gt->hwmon_dev) { > > + hwmon_device_unregister(ddat_gt->hwmon_dev); > > + ddat_gt->hwmon_dev = NULL; > > + } > > + } > > + > > + if (ddat->hwmon_dev) > > + hwmon_device_unregister(ddat->hwmon_dev); > > + > > + mutex_destroy(&hwmon->hwmon_lock); > > + kfree(hwmon); > > } > > -- > > 2.41.0 > >