Commit 2bdc55d9 authored by J. German Rivera's avatar J. German Rivera Committed by Greg Kroah-Hartman

staging: fsl-mc: Fix crash in fsl_mc_device_remove()

Only call fsl_mc_io_destroy() if the DPRC being removed
actually had an mc_io object associated with. Child DPRCs
that have not been bound to the DPRC driver or the VFIO driver
will not have an mc_io associated with them.
Signed-off-by: default avatarJ. German Rivera <German.Rivera@freescale.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1663e809
......@@ -167,7 +167,6 @@ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
for (i = 0; i < num_child_objects_in_mc; i++) {
struct fsl_mc_device *child_dev;
struct fsl_mc_io *mc_io = NULL;
struct dprc_obj_desc *obj_desc = &obj_desc_array[i];
if (strlen(obj_desc->type) == 0)
......@@ -182,15 +181,11 @@ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
continue;
}
error = fsl_mc_device_add(obj_desc, mc_io, &mc_bus_dev->dev,
error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev,
&child_dev);
if (error < 0) {
if (mc_io)
fsl_destroy_mc_io(mc_io);
if (error < 0)
continue;
}
}
}
static void dprc_init_all_resource_pools(struct fsl_mc_device *mc_bus_dev)
......
......@@ -444,15 +444,16 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev)
put_device(&mc_dev->dev);
if (strcmp(mc_dev->obj_desc.type, "dprc") == 0) {
struct fsl_mc_io *mc_io = mc_dev->mc_io;
mc_bus = to_fsl_mc_bus(mc_dev);
fsl_destroy_mc_io(mc_io);
if (mc_dev->mc_io) {
fsl_destroy_mc_io(mc_dev->mc_io);
mc_dev->mc_io = NULL;
}
if (&mc_dev->dev == fsl_mc_bus_type.dev_root)
fsl_mc_bus_type.dev_root = NULL;
}
mc_dev->mc_io = NULL;
if (mc_bus)
devm_kfree(mc_dev->dev.parent, mc_bus);
else
......
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