Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp984920lqz; Sun, 31 Mar 2024 08:11:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMW6EHUTV+Ehe/PoeHMpdNAVwOJHLIgeaU7mMna2fdNV9ECfEgOFp9sdwOQeQnxJOeEhyKiPvuEefXZuVW4VhAiOUQ4V8Y96snHZhjug== X-Google-Smtp-Source: AGHT+IFUyMh2DcV82Gi9kIHh/hsaY5Eu77Z7GtK3owOmPf76NGj84KjGlHIsTJZe/jw/c2YvqAux X-Received: by 2002:a05:6e02:18c9:b0:368:a8b6:2a64 with SMTP id s9-20020a056e0218c900b00368a8b62a64mr9222040ilu.20.1711897900584; Sun, 31 Mar 2024 08:11:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711897900; cv=pass; d=google.com; s=arc-20160816; b=rNtZ0mzjhUs0M5UyNboN5czXE3TUR2Er1DPzF3AdqWh0r+pWCJdm9+Je2kJ7hbFt9G 1ifd/wF+wzSqsc/1bPP4/BTOaykpmG85WH53zh9YNWBF10ZdxScQrMhef0xQh3mbGhj8 WW75D6etjg3zLeGkB1cvtDwodyPogWLFZZzt60oTTIKO+XtQGd3HU1NUTtDCY9tOTv2c onYgK8yy7Gy0jtjF+ONcXUeSnUJALALyl5xv10mEkhBai8kLBVdK/SZXWQffKZq+o8HW cuKgfCpTjA2b6xEUi8rqVzv6etLpOMZNrquSYb2l5Eb8/Rx1qPxpSIDTkUsLu+dsj3pZ nRoQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zgJl48GpS/xPPGbS31YUU8wawJAP1cqj1jNtmpn/C2o=; fh=9RvofxN2HDhir9caJGvN6UMPCGNY8DPeIfwy+sOZG4c=; b=OTYeuX9R3LXWIiyM+cQ1kwxUw9XtN4QbuQPk2j8lOnSExI537znYNdI8EZMbOW8Vt+ 8K5Y3+3pZu0p3S0mpsRHV5drAn9Oe8mtI75V/NcnYXWQeTxyMA27D6VW4MhtCubS5/CQ hW2qO6OdVQ+zzA+YWL07+QJ+hlMVdzSMTVNu8vigB0JJXUBo8gvBA5u0TMxtprKohqCP jJgIXnJ2o0c+vAS+O1RZ1TrC6mHG29bzg3Ey1klPnLigBl6+ayxSS6Ebjswl0lTwkkf+ uGpRBEqmv6dsQGIwJB2as2bR+FDuRA9hBzvglVbmkJ5RTtw8xU22fOY8U5BiejHm8/Xu I3MQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Aw5NpLdd; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-126082-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126082-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q76-20020a632a4f000000b005dc95934e54si7689618pgq.52.2024.03.31.08.11.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Mar 2024 08:11:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126082-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Aw5NpLdd; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-126082-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126082-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 912D4B20B01 for ; Sun, 31 Mar 2024 13:53:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAA82144D28; Sun, 31 Mar 2024 13:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Aw5NpLdd" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13A78144D13; Sun, 31 Mar 2024 13:53:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711893227; cv=none; b=EaHlHb7iabf99+W+XF0s18Hw45UaQvTdc+QHf9XMrWq7Sy4QKDegK2i0FxZoe0PaTaKShk3aQ964HIrrxhZM0ekaV7v1nbpnjfafd5p8bMxyEoqp4237OCaYcTFQWEdUSl8XzPazjNGLI3cmjGkeNvjIbu7RN/dQf/1jhyVlikE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711893227; c=relaxed/simple; bh=HZcoANQm+m6eHWitU14xeSVvP4uJHQVXHY2wtEadUVc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jriDqskD3O5Iu2ZmyfKR7SoWMaJVsfkirQELfUW/b1lceQquXzf2j9kfWGPwM3KMZe7I7W2yN0r2YO070JBsB/xOqdOelWiBD7Dl7y3CRX2GZnjvlWQSxjHb8HszhjJf8upl9I7iTNbchvx5dwuBnwKPQ0N24W2DudhN1D/BdCU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Aw5NpLdd; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711893225; x=1743429225; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=HZcoANQm+m6eHWitU14xeSVvP4uJHQVXHY2wtEadUVc=; b=Aw5NpLddqUOsWbLgnP9S67YVMubFkiAgftYxkUl0uoXI2RcEgz9jJEtC cJUptNxm5sNy0+WQy2AdlNa3yMF1TcHWxjWa9KkAgdUf1F1heg5yqjr07 mcEL0J5I5Hqb0N0Kk4tEde9pgf+jFW6pWkkg6cJwOfvVuylDDaJb8y1+x J/TZEWns8yqNj1lUC/oHiwcEeSnNYrOhZvSqXdOl7/MZ4WE0oBROglRnV 0f6oPDtaWzsZqR8VI+bepjqDh6XD1BOfSZlk+G3UB1FdRPdku9zj1DAUP cgv0yGjYoeW8PPCofeb6wTwL0xZMYmTPMC3GO40rq/7PP0SVImSRPttd/ Q==; X-CSE-ConnectionGUID: 4z/g0kh8RlayBo8RQxEVnA== X-CSE-MsgGUID: sSxvBCWxSTeJFOhR7wLxEQ== X-IronPort-AV: E=McAfee;i="6600,9927,11030"; a="7240446" X-IronPort-AV: E=Sophos;i="6.07,170,1708416000"; d="scan'208";a="7240446" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2024 06:53:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,170,1708416000"; d="scan'208";a="21896299" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmviesa005.fm.intel.com with ESMTP; 31 Mar 2024 06:53:41 -0700 Date: Sun, 31 Mar 2024 21:48:52 +0800 From: Xu Yilun To: Marco Pagani Cc: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , Jonathan Corbet , Greg Kroah-Hartman , Alan Tull , Russ Weight , linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] fpga: bridge: add owner module and take its refcount Message-ID: References: <20240322171839.233864-1-marpagan@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240322171839.233864-1-marpagan@redhat.com> On Fri, Mar 22, 2024 at 06:18:37PM +0100, Marco Pagani wrote: > The current implementation of the fpga bridge assumes that the low-level > module registers a driver for the parent device and uses its owner pointer > to take the module's refcount. This approach is problematic since it can > lead to a null pointer dereference while attempting to get the bridge if > the parent device does not have a driver. > > To address this problem, add a module owner pointer to the fpga_bridge > struct and use it to take the module's refcount. Modify the function for > registering a bridge to take an additional owner module parameter and > rename it to avoid conflicts. Use the old function name for a helper macro > that automatically sets the module that registers the bridge as the owner. > This ensures compatibility with existing low-level control modules and > reduces the chances of registering a bridge without setting the owner. > > Also, update the documentation to keep it consistent with the new interface > for registering an fpga bridge. > > Other changes: opportunistically move put_device() from __fpga_bridge_get() > to fpga_bridge_get() and of_fpga_bridge_get() to improve code clarity since > the bridge device is taken in these functions. > > Fixes: 21aeda950c5f ("fpga: add fpga bridge framework") > Suggested-by: Greg Kroah-Hartman > Suggested-by: Xu Yilun > Reviewed-by: Russ Weight > Signed-off-by: Marco Pagani Acked-by: Xu Yilun Applied to for-next.