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]
Date:   Thu, 3 Jun 2021 06:18:46 -0700
From:   Richard Cochran <richardcochran@...il.com>
To:     Guangbin Huang <huangguangbin2@...wei.com>
Cc:     davem@...emloft.net, kuba@...nel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, salil.mehta@...wei.com,
        lipeng321@...wei.com, tanhuazhong@...wei.com
Subject: Re: [RESEND net-next 1/2] net: hns3: add support for PTP

On Wed, Jun 02, 2021 at 10:57:43AM +0800, Guangbin Huang wrote:

> +static int hclge_ptp_create_clock(struct hclge_dev *hdev)
> +{
> +#define HCLGE_PTP_NAME_LEN	32
> +
> +	struct hclge_ptp *ptp;
> +
> +	ptp = devm_kzalloc(&hdev->pdev->dev, sizeof(*ptp), GFP_KERNEL);
> +	if (!ptp)
> +		return -ENOMEM;
> +
> +	ptp->hdev = hdev;
> +	snprintf(ptp->info.name, HCLGE_PTP_NAME_LEN, "%s",
> +		 HCLGE_DRIVER_NAME);
> +	ptp->info.owner = THIS_MODULE;
> +	ptp->info.max_adj = HCLGE_PTP_CYCLE_ADJ_MAX;
> +	ptp->info.n_ext_ts = 0;
> +	ptp->info.pps = 0;
> +	ptp->info.adjfreq = hclge_ptp_adjfreq;
> +	ptp->info.adjtime = hclge_ptp_adjtime;
> +	ptp->info.gettimex64 = hclge_ptp_gettimex;
> +	ptp->info.settime64 = hclge_ptp_settime;
> +
> +	ptp->info.n_alarm = 0;
> +	ptp->clock = ptp_clock_register(&ptp->info, &hdev->pdev->dev);
> +	if (IS_ERR(ptp->clock)) {
> +		dev_err(&hdev->pdev->dev, "%d failed to register ptp clock, ret = %ld\n",
> +			ptp->info.n_alarm, PTR_ERR(ptp->clock));
> +		return PTR_ERR(ptp->clock);
> +	}

You must handle the case where NULL is returned.

 * ptp_clock_register() - register a PTP hardware clock driver
 *
 * @info:   Structure describing the new clock.
 * @parent: Pointer to the parent device of the new clock.
 *
 * Returns a valid pointer on success or PTR_ERR on failure.  If PHC
 * support is missing at the configuration level, this function
 * returns NULL, and drivers are expected to gracefully handle that
 * case separately.

> +
> +	ptp->io_base = hdev->hw.io_base + HCLGE_PTP_REG_OFFSET;
> +	ptp->ts_cfg.rx_filter = HWTSTAMP_FILTER_NONE;
> +	ptp->ts_cfg.tx_type = HWTSTAMP_TX_OFF;
> +	hdev->ptp = ptp;
> +
> +	return 0;
> +}

Thanks,
Richard

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ