Search Linux Wireless

Re: [PATCH v7 13/16] power: sequencing: implement the pwrseq core

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 10, 2024 at 02:46:25PM +0200, Bartosz Golaszewski wrote:

...

> +/**
> + * pwrseq_device_register() - Register a new power sequencer.
> + * @config: Configuration of the new power sequencing device.
> + *
> + * The config structure is only used during the call and can be freed after
> + * the function returns. The config structure *must* have the parent device
> + * as well as the match() callback and at least one target set.
> + *
> + * Returns:
> + * Returns the address of the new pwrseq device or ERR_PTR() on failure.
> + */
> +struct pwrseq_device *
> +pwrseq_device_register(const struct pwrseq_config *config)
> +{
> +	struct pwrseq_device *pwrseq;
> +	int ret;
> +
> +	if (!config->parent || !config->match || !config->targets ||
> +	    !config->targets[0])
> +		return ERR_PTR(-EINVAL);
> +
> +	pwrseq = kzalloc(sizeof(*pwrseq), GFP_KERNEL);
> +	if (!pwrseq)
> +		return ERR_PTR(-ENOMEM);
> +
> +	pwrseq->dev.type = &pwrseq_device_type;
> +	pwrseq->dev.bus = &pwrseq_bus;
> +	pwrseq->dev.parent = config->parent;
> +	device_set_node(&pwrseq->dev, dev_fwnode(config->parent));
> +	dev_set_drvdata(&pwrseq->dev, config->drvdata);
> +
> +	pwrseq->id = ida_alloc(&pwrseq_ida, GFP_KERNEL);
> +	if (pwrseq->id < 0) {
> +		kfree(pwrseq);

Hi Bartosz,

pwrseq is freed on the line above,
so it should not be dereferenced on the line below.

Flagged by Smatch.

> +		return ERR_PTR(pwrseq->id);
> +	}

...




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux