Re: [PATCH v13 03/11] reset: realtek: Add RTD1625 reset controller driver

[email protected]
Newsgroups org.kernel.vger.linux-clk,org.kernel.vger.linux-devicetree
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing validation of `dev_get_platdata()` return value, leading to a potential NULL pointer dereference in reset operations.
--

--- Patch [3]: [PATCH v13 03/11] reset: realtek: Add RTD1625 reset controller driver ---
commit 789f70d6384140bb43211f942b168ac28816b10c
Author: Cheng-Yu Lee <[email protected]>

reset: realtek: Add RTD1625 reset controller driver

This commit adds support for the CRT and ISO domain reset controller on
the Realtek RTD1625 SoC. The reset driver is implemented as an auxiliary
driver to handle shared register space with the clock controller.

> diff --git a/drivers/reset/realtek/reset-rtd1625.c b/drivers/reset/realtek/reset-rtd1625.c
> new file mode 100644
> index 0000000000000..479b3a94d2b5a
> --- /dev/null
> +++ b/drivers/reset/realtek/reset-rtd1625.c

[ ... ]

> +static int rtd1625_reset_probe(struct auxiliary_device *adev,
> +			       const struct auxiliary_device_id *id)
> +{
> +	const struct rtd1625_reset_info *info;
> +	struct device *dev = &adev->dev;
> +	struct rtk_reset_data *data;
> +
> +	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;
> +
> +	info = (const struct rtd1625_reset_info *)id->driver_data;
> +
> +	data->descs           = info->descs;
> +	data->regmap          = dev_get_platdata(dev);

[Severity: Medium]
Should there be a check to ensure dev_get_platdata() does not return NULL?

If the parent clock controller driver fails to populate the platform data
for the auxiliary device before adding it to the auxiliary bus, this could
lead to a NULL pointer being assigned to data->regmap. This might result
in a kernel panic during later reset operations (such as assert or deassert)
when the regmap is dereferenced by rtk_reset_ops.

> +	data->rcdev.owner     = THIS_MODULE;
> +	data->rcdev.nr_resets = info->nr_resets;
> +	data->rcdev.ops       = &rtk_reset_ops;
> +	data->rcdev.dev       = dev;
> +	data->rcdev.of_node   = dev->of_node;
> +
> +	return devm_reset_controller_register(dev, &data->rcdev);
> +}

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.