diff options
author | Christian Gromm <christian.gromm@microchip.com> | 2018-08-13 15:02:28 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-08-27 19:51:49 +0200 |
commit | f0b4a22a48481824e124f633bbe5d3e884fc8e36 (patch) | |
tree | 650bb3cd4f3af2d39c0a9b3c3210e3cef18a05bb /drivers/staging | |
parent | 23c41ca6173da88c4acff1e353af654085ee3a0d (diff) | |
download | linux-f0b4a22a48481824e124f633bbe5d3e884fc8e36.tar.gz linux-f0b4a22a48481824e124f633bbe5d3e884fc8e36.tar.bz2 linux-f0b4a22a48481824e124f633bbe5d3e884fc8e36.zip |
staging: most: register channel device after init of struct members
This patch moves the call to device_register to the end of the channel
initialization section that the devcie belongs to. It is needed to
avoid NULL pointer dereferences once the device is registered with
sysfs.
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/most/core.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c index f4c464625a67..b59e4711b62f 100644 --- a/drivers/staging/most/core.c +++ b/drivers/staging/most/core.c @@ -1439,10 +1439,6 @@ int most_register_interface(struct most_interface *iface) c->dev.parent = &iface->dev; c->dev.groups = channel_attr_groups; c->dev.release = release_channel; - if (device_register(&c->dev)) { - pr_err("registering c->dev failed\n"); - goto free_instance_nodev; - } iface->p->channel[i] = c; c->is_starving = 0; c->iface = iface; @@ -1465,6 +1461,10 @@ int most_register_interface(struct most_interface *iface) mutex_init(&c->start_mutex); mutex_init(&c->nq_mutex); list_add_tail(&c->list, &iface->p->channel_list); + if (device_register(&c->dev)) { + pr_err("registering c->dev failed\n"); + goto free_instance_nodev; + } } pr_info("registered new device mdev%d (%s)\n", id, iface->description); |