Commit 51259277 authored by Alexander Shishkin's avatar Alexander Shishkin Committed by Greg Kroah-Hartman

intel_th: Fix a double put_device() in error path

Commit a753bfcf ("intel_th: Make the switch allocate its subdevices")
factored out intel_th_subdevice_alloc() from intel_th_populate(), but got
the error path wrong, resulting in two instances of a double put_device()
on a freshly initialized, but not 'added' device.

Fix this by only doing one put_device() in the error path.
Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: a753bfcf ("intel_th: Make the switch allocate its subdevices")
Reported-by: default avatarWen Yang <wenyang@linux.alibaba.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: stable@vger.kernel.org # v4.14+
Link: https://lore.kernel.org/r/20191120130806.44028-2-alexander.shishkin@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9a5d847c
...@@ -649,10 +649,8 @@ intel_th_subdevice_alloc(struct intel_th *th, ...@@ -649,10 +649,8 @@ intel_th_subdevice_alloc(struct intel_th *th,
} }
err = intel_th_device_add_resources(thdev, res, subdev->nres); err = intel_th_device_add_resources(thdev, res, subdev->nres);
if (err) { if (err)
put_device(&thdev->dev);
goto fail_put_device; goto fail_put_device;
}
if (subdev->type == INTEL_TH_OUTPUT) { if (subdev->type == INTEL_TH_OUTPUT) {
if (subdev->mknode) if (subdev->mknode)
...@@ -667,10 +665,8 @@ intel_th_subdevice_alloc(struct intel_th *th, ...@@ -667,10 +665,8 @@ intel_th_subdevice_alloc(struct intel_th *th,
} }
err = device_add(&thdev->dev); err = device_add(&thdev->dev);
if (err) { if (err)
put_device(&thdev->dev);
goto fail_free_res; goto fail_free_res;
}
/* need switch driver to be loaded to enumerate the rest */ /* need switch driver to be loaded to enumerate the rest */
if (subdev->type == INTEL_TH_SWITCH && !req) { if (subdev->type == INTEL_TH_SWITCH && !req) {
......
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