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: <eafb409d-5b5f-4791-939a-5a3c1eb00b9b@kernel.org>
Date: Sat, 6 Sep 2025 14:19:30 +0200
From: Krzysztof Kozlowski <krzk@...nel.org>
To: Tudor Ambarus <tudor.ambarus@...aro.org>, Rob Herring <robh@...nel.org>,
 Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
 <conor+dt@...nel.org>, Peter Griffin <peter.griffin@...aro.org>,
 André Draszik <andre.draszik@...aro.org>,
 Michael Turquette <mturquette@...libre.com>, Stephen Boyd
 <sboyd@...nel.org>, Alim Akhtar <alim.akhtar@...sung.com>,
 Sylwester Nawrocki <s.nawrocki@...sung.com>,
 Chanwoo Choi <cw00.choi@...sung.com>,
 Catalin Marinas <catalin.marinas@....com>, Will Deacon <will@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-samsung-soc@...r.kernel.org,
 devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
 linux-clk@...r.kernel.org, willmcvicker@...gle.com, kernel-team@...roid.com
Subject: Re: [PATCH v3 3/5] clk: samsung: add Exynos ACPM clock driver

On 03/09/2025 15:56, Tudor Ambarus wrote:
> +
> +static int acpm_clk_probe(struct platform_device *pdev)
> +{
> +	enum acpm_clk_dev_type type = platform_get_device_id(pdev)->driver_data;
> +	const struct acpm_clk_driver_data *drv_data;
> +	const struct acpm_handle *acpm_handle;
> +	struct clk_hw_onecell_data *clk_data;
> +	struct clk_hw **hws;
> +	struct device *dev = &pdev->dev;
> +	struct acpm_clk *aclks;
> +	unsigned int mbox_chan_id;
> +	int i, err, count;
> +
> +	switch (type) {
> +	case GS101_ACPM_CLK_ID:
> +		drv_data = &acpm_clk_gs101;

Just use acpm_clk_gs101 directly (see also further comment).

> +		break;
> +	default:
> +		return dev_err_probe(dev, -EINVAL, "Invalid device type\n");
> +	}
> +
> +	acpm_handle = devm_acpm_get_by_node(dev, dev->parent->of_node);
> +	if (IS_ERR(acpm_handle))
> +		return dev_err_probe(dev, PTR_ERR(acpm_handle),
> +				     "Failed to get acpm handle.\n");
> +
> +	count = drv_data->nr_clks;
> +	mbox_chan_id = drv_data->mbox_chan_id;
> +
> +	clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, count),
> +				GFP_KERNEL);
> +	if (!clk_data)
> +		return -ENOMEM;
> +
> +	clk_data->num = count;
> +	hws = clk_data->hws;
> +
> +	aclks = devm_kcalloc(dev, count, sizeof(*aclks), GFP_KERNEL);
> +	if (!aclks)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < count; i++) {
> +		const struct acpm_clk_variant *variant = &drv_data->clks[i];
> +		unsigned int id = variant->id;
> +		struct acpm_clk *aclk;
> +
> +		if (id >= count)

This is not possible. You control the IDs build time, so this must be
either build time check or no check. I vote for no check, because I
don't think the ID is anyhow related to number of clocks. What if (not
recommended but what if) the IDs have a gap and next ID is 1000. I see
your code using ID:


> +			return dev_err_probe(dev, -EINVAL,
> +					     "Invalid ACPM clock ID.\n");
> +
> +		aclk = &aclks[id];
> +		aclk->id = id;
> +		aclk->handle = acpm_handle;
> +		aclk->mbox_chan_id = mbox_chan_id;
> +
> +		hws[id] = &aclk->hw;

^^^ here, but why do you need it? Why it cannot be hws[i]?

> +
> +		err = acpm_clk_ops_init(dev, aclk, variant->name);
> +		if (err)
> +			return dev_err_probe(dev, err,
> +					     "Failed to register clock.\n");
> +	}
> +
> +	return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
> +					   clk_data);
> +}
> +
> +static const struct platform_device_id acpm_clk_id[] = {
> +	{ "gs101-acpm-clk", GS101_ACPM_CLK_ID },

Please drop GS101_ACPM_CLK_ID here and in other places. It's dead code
now. It should be introduced with next users/devices.

> +	{},
> +};
> +MODULE_DEVICE_TABLE(platform, acpm_clk_id);

Best regards,
Krzysztof

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ