linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Milton Miller <miltonm@bga.com>
To: Mark Zhan <rongkai.zhan@windriver.com>
Cc: ppcdev <linuxppc-dev@ozlabs.org>
Subject: racy calls to platform_device_add_data after platform_device_register_simple
Date: Mon, 11 Jun 2007 10:27:21 -0500	[thread overview]
Message-ID: <10a84b95ad7ec502b5ca8c5af5d9d497@bga.com> (raw)

On Fri Jun 8 18:54:38 EST 2007, Mark Zhan wrote:
> @@ -775,38 +774,42 @@ static int __init cpm_uart_of_init(void)
> +               if (strstr(model, "SMC")) {
> +                       cpm_uart_dev = 
> platform_device_register_simple("fsl-cpm-smc:uart",
> +                                                       i, &r[0], 3);
> +               } else if (strstr(model, "SCC")) {
> +                       cpm_uart_dev = 
> platform_device_register_simple("fsl-cpm-scc:uart",
> +                                                       i, &r[0], 3);
> +               }
> +
> +               if (IS_ERR(cpm_uart_dev)) {
> +                       ret = PTR_ERR(cpm_uart_dev);
> +                       goto err;
> +               }
>
> +               cpm_uart_data.uart_clk = ppc_proc_freq;
>                 cpm_uart_data.tx_num_fifo = 4;
>                 cpm_uart_data.tx_buf_size = 32;
>                 cpm_uart_data.rx_num_fifo = 4;
> @@ -816,10 +819,8 @@ static int __init cpm_uart_of_init(void)
>                 cpm_uart_data.clk_tx = *((u32 *)of_get_property(np,
>                                                 "tx-clock", NULL));
>
> -               ret =
> -                   platform_device_add_data(cpm_uart_dev, 
> &cpm_uart_data,
> -                                            sizeof(struct
> -                                                   
> fs_uart_platform_info));
> +               ret = platform_device_add_data(cpm_uart_dev, 
> &cpm_uart_data,
> +                                       sizeof(struct 
> fs_uart_platform_info));

This code (and others like the ethernet code above it) is racy in that 
the device is visible to the device layer without all of the data 
needed by the driver.  Since its being run as an arch_initcall, the 
driver is not yet registered so its not quite a bug yet.

Since this seems to be appearing frequently as we add wrappers from the 
device tree to the subsystem layer drivers, we should create an 
extended function that takes a data pointer and size (NULL/zero would 
mean none), and define platform_device_register_simple in terms of it.

milton

                 reply	other threads:[~2007-06-11 15:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=10a84b95ad7ec502b5ca8c5af5d9d497@bga.com \
    --to=miltonm@bga.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=rongkai.zhan@windriver.com \
    /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;
as well as URLs for NNTP newsgroup(s).