mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: marc.ferland@gmail.com, krzysztof.kozlowski@linaro.org
Cc: gregkh@linuxfoundation.org, marc.ferland@sonatest.com,
	jeff.dagenais@gmail.com, rdunlap@infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/5] w1: ds2433: introduce a configuration structure
Date: Sat, 2 Dec 2023 13:06:18 +0100	[thread overview]
Message-ID: <406ec8fe-a407-446b-a368-c68e90f1249a@kernel.org> (raw)
In-Reply-To: <20231130135232.191320-4-marc.ferland@sonatest.com>

On 30/11/2023 14:52, marc.ferland@gmail.com wrote:
>  static int w1_f23_add_slave(struct w1_slave *sl)
>  {
> -#ifdef CONFIG_W1_SLAVE_DS2433_CRC
>  	struct w1_f23_data *data;
>  
>  	data = kzalloc(sizeof(struct w1_f23_data), GFP_KERNEL);
>  	if (!data)
>  		return -ENOMEM;
> +
> +	data->cfg = &config_f23;
> +
> +#ifdef CONFIG_W1_SLAVE_DS2433_CRC
> +	data->memory = kzalloc(data->cfg->eeprom_size, GFP_KERNEL);
> +	if (!data->memory) {
> +		kfree(data);
> +		return -ENOMEM;
> +	}
> +#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
>  	sl->family_data = data;
>  
> -#endif	/* CONFIG_W1_SLAVE_DS2433_CRC */
>  	return 0;
>  }
>  
>  static void w1_f23_remove_slave(struct w1_slave *sl)
>  {
> +	struct w1_f23_data *data = sl->family_data;
>  #ifdef CONFIG_W1_SLAVE_DS2433_CRC
> -	kfree(sl->family_data);
> +	kfree(data->memory);
> +#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
> +	kfree(data);
>  	sl->family_data = NULL;

This should be before kfree(), to match w1_f23_add_slave(). You can move
it now, since you store the pointer in data.

> -#endif	/* CONFIG_W1_SLAVE_DS2433_CRC */
>  }
>  
>  static const struct w1_family_ops w1_f23_fops = {

Best regards,
Krzysztof


  reply	other threads:[~2023-12-02 12:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 13:52 [PATCH v3 0/5] Add support for the ds28ec20 one-wire eeprom marc.ferland
2023-11-30 13:52 ` [PATCH v3 1/5] w1: ds2490: support block sizes larger than 128 bytes in ds_read_block marc.ferland
2023-12-02 12:01   ` Krzysztof Kozlowski
2023-11-30 13:52 ` [PATCH v3 2/5] w1: ds2433: remove unused definition marc.ferland
2023-12-02 12:02   ` Krzysztof Kozlowski
2023-11-30 13:52 ` [PATCH v3 3/5] w1: ds2433: introduce a configuration structure marc.ferland
2023-12-02 12:06   ` Krzysztof Kozlowski [this message]
2023-11-30 13:52 ` [PATCH v3 4/5] w1: ds2433: use the kernel bitmap implementation marc.ferland
2023-11-30 14:52   ` David Laight
2023-11-30 15:10     ` Marc Ferland
2023-11-30 13:52 ` [PATCH v3 5/5] w1: ds2433: add support for ds28ec20 eeprom marc.ferland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=406ec8fe-a407-446b-a368-c68e90f1249a@kernel.org \
    --to=krzk@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeff.dagenais@gmail.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.ferland@gmail.com \
    --cc=marc.ferland@sonatest.com \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®