mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 02:50:43 +00:00
greybus: module: don't create duplicate module ids
If we somehow get a hotplug event for a module id that we already have created[1], don't try to create it again, or sysfs will complain loudly. Instead, abort the creation properly. [1] If, for example, you happened to run a script on a greybus emulator twice in a row... Signed-off-by: Greg Kroah-Hartman <greg@kroah.com> Reviewed-by: Alex Elder <elder@linaro.org>
This commit is contained in:
parent
3e6d5f3a61
commit
066799c18f
1 changed files with 7 additions and 0 deletions
|
@ -70,6 +70,13 @@ struct gb_module *gb_module_create(struct greybus_host_device *hd, u8 module_id)
|
|||
struct gb_module *gmod;
|
||||
int retval;
|
||||
|
||||
gmod = gb_module_find(hd, module_id);
|
||||
if (gmod) {
|
||||
dev_err(hd->parent, "Duplicate module id %d will not be created\n",
|
||||
module_id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gmod = kzalloc(sizeof(*gmod), GFP_KERNEL);
|
||||
if (!gmod)
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in a new issue