Subject: Re: [PATCH v4 07/14] net-next/yunsilicon: Init auxiliary device

From: Leon Romanovsky <[email-masked]>
Date: Sun, 16 Feb 2025 11:59:15 +0200

On Fri, Feb 14, 2025 at 11:14:45AM +0800, tianx wrote:
> On 2025/2/13 22:37, Leon Romanovsky wrote:
> > On Thu, Feb 13, 2025 at 05:14:19PM +0800, Xin Tian wrote:
> >> Initialize eth auxiliary device when pci probing
> >>
> >> Co-developed-by: Honggang Wei <[email-masked]>
> >> Signed-off-by: Honggang Wei <[email-masked]>
> >> Co-developed-by: Lei Yan <[email-masked]>
> >> Signed-off-by: Lei Yan <[email-masked]>
> >> Signed-off-by: Xin Tian <[email-masked]>
> >> ---
> >>   .../ethernet/yunsilicon/xsc/common/xsc_core.h |  12 ++
> >>   .../net/ethernet/yunsilicon/xsc/pci/Makefile  |   3 +-
> >>   .../net/ethernet/yunsilicon/xsc/pci/adev.c    | 110 ++++++++++++++++++
> >>   .../net/ethernet/yunsilicon/xsc/pci/adev.h    |  14 +++
> >>   .../net/ethernet/yunsilicon/xsc/pci/main.c    |  10 ++
> >>   5 files changed, 148 insertions(+), 1 deletion(-)
> >>   create mode 100644 drivers/net/ethernet/yunsilicon/xsc/pci/adev.c
> >>   create mode 100644 drivers/net/ethernet/yunsilicon/xsc/pci/adev.h
> > <...>

<...>

> >> +	[XSC_ADEV_IDX_ETH] = XSC_ETH_ADEV_NAME,
> >> +};
> >> +
> >> +static void xsc_release_adev(struct device *dev)
> >> +{
> >> +	/* Doing nothing, but auxiliary bus requires a release function */
> >> +}
> > It is unlikely to be true in driver lifetime model. At least you should
> > free xsc_adev here.
> >
> > Thanks
> 
> Hi Leon, xsc_adev has already been freed after calling 
> auxiliary_device_uninit. If I free it again in the release callback, it 
> will cause a double free.

You should follow standard driver lifetime model. Your
auxiliary_device_uninit() is wrong and shouldn't exist from the
beginning.

Thanks