lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <0e83c125-b69e-46a0-a760-fe090b53bc70@yunsilicon.com>
Date: Fri, 14 Feb 2025 11:14:45 +0800
From: "tianx" <tianx@...silicon.com>
To: "Leon Romanovsky" <leon@...nel.org>
Cc: <netdev@...r.kernel.org>, <andrew+netdev@...n.ch>, <kuba@...nel.org>, 
	<pabeni@...hat.com>, <edumazet@...gle.com>, <davem@...emloft.net>, 
	<jeff.johnson@....qualcomm.com>, <przemyslaw.kitszel@...el.com>, 
	<weihg@...silicon.com>, <wanry@...silicon.com>, <horms@...nel.org>, 
	<parthiban.veerasooran@...rochip.com>, <masahiroy@...nel.org>
Subject: Re: [PATCH v4 07/14] net-next/yunsilicon: Init auxiliary device

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 <weihg@...silicon.com>
>> Signed-off-by: Honggang Wei <weihg@...silicon.com>
>> Co-developed-by: Lei Yan <jacky@...silicon.com>
>> Signed-off-by: Lei Yan <jacky@...silicon.com>
>> Signed-off-by: Xin Tian <tianx@...silicon.com>
>> ---
>>   .../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
> <...>
>
>> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/adev.c b/drivers/net/ethernet/yunsilicon/xsc/pci/adev.c
>> new file mode 100644
>> index 000000000..1f8f27d72
>> --- /dev/null
>> +++ b/drivers/net/ethernet/yunsilicon/xsc/pci/adev.c
>> @@ -0,0 +1,110 @@
>> +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
>> +/*
>> + * Copyright (C) 2021-2025, Shanghai Yunsilicon Technology Co., Ltd.
>> + * All rights reserved.
>> + */
>> +
>> +#include <linux/auxiliary_bus.h>
>> +#include <linux/idr.h>
>> +
>> +#include "adev.h"
>> +
>> +static DEFINE_IDA(xsc_adev_ida);
>> +
>> +enum xsc_adev_idx {
>> +	XSC_ADEV_IDX_ETH,
>> +	XSC_ADEV_IDX_MAX
>> +};
>> +
>> +static const char * const xsc_adev_name[] = {
>> +	[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.

>> +
>> +static int xsc_reg_adev(struct xsc_core_device *xdev, int idx)
>> +{
>> +	struct auxiliary_device	*adev;
>> +	struct xsc_adev *xsc_adev;
>> +	int ret;
>> +
>> +	xsc_adev = kzalloc(sizeof(*xsc_adev), GFP_KERNEL);
>> +	if (!xsc_adev)
>> +		return -ENOMEM;
>> +
>> +	adev = &xsc_adev->adev;
>> +	adev->name = xsc_adev_name[idx];
>> +	adev->id = xdev->adev_id;
>> +	adev->dev.parent = &xdev->pdev->dev;
>> +	adev->dev.release = xsc_release_adev;
>> +	xsc_adev->xdev = xdev;
>> +
>> +	ret = auxiliary_device_init(adev);
>> +	if (ret)
>> +		goto err_free_adev;
>> +
>> +	ret = auxiliary_device_add(adev);
>> +	if (ret)
>> +		goto err_uninit_adev;
>> +
>> +	xdev->xsc_adev_list[idx] = xsc_adev;
>> +
>> +	return 0;
>> +err_uninit_adev:
>> +	auxiliary_device_uninit(adev);
>> +err_free_adev:
>> +	kfree(xsc_adev);
>> +

>> +	return ret;
>> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ