Commit f0b4a22a authored by Christian Gromm's avatar Christian Gromm Committed by Greg Kroah-Hartman

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: default avatarChristian Gromm <christian.gromm@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 23c41ca6
...@@ -1439,10 +1439,6 @@ int most_register_interface(struct most_interface *iface) ...@@ -1439,10 +1439,6 @@ int most_register_interface(struct most_interface *iface)
c->dev.parent = &iface->dev; c->dev.parent = &iface->dev;
c->dev.groups = channel_attr_groups; c->dev.groups = channel_attr_groups;
c->dev.release = release_channel; 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; iface->p->channel[i] = c;
c->is_starving = 0; c->is_starving = 0;
c->iface = iface; c->iface = iface;
...@@ -1465,6 +1461,10 @@ int most_register_interface(struct most_interface *iface) ...@@ -1465,6 +1461,10 @@ int most_register_interface(struct most_interface *iface)
mutex_init(&c->start_mutex); mutex_init(&c->start_mutex);
mutex_init(&c->nq_mutex); mutex_init(&c->nq_mutex);
list_add_tail(&c->list, &iface->p->channel_list); 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", pr_info("registered new device mdev%d (%s)\n",
id, iface->description); id, iface->description);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment