Skip to content

Commit

Permalink
intel_th: Fix a double put_device() in error path
Browse files Browse the repository at this point in the history
Commit a753bfc ("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: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: a753bfc ("intel_th: Make the switch allocate its subdevices")
Reported-by: Wen Yang <wenyang@linux.alibaba.com>
Reviewed-by: Andy 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.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
virtuoso authored and gregkh committed Nov 20, 2019
1 parent 9a5d847 commit 5125927
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/hwtracing/intel_th/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,10 +649,8 @@ intel_th_subdevice_alloc(struct intel_th *th,
}

err = intel_th_device_add_resources(thdev, res, subdev->nres);
if (err) {
put_device(&thdev->dev);
if (err)
goto fail_put_device;
}

if (subdev->type == INTEL_TH_OUTPUT) {
if (subdev->mknode)
Expand All @@ -667,10 +665,8 @@ intel_th_subdevice_alloc(struct intel_th *th,
}

err = device_add(&thdev->dev);
if (err) {
put_device(&thdev->dev);
if (err)
goto fail_free_res;
}

/* need switch driver to be loaded to enumerate the rest */
if (subdev->type == INTEL_TH_SWITCH && !req) {
Expand Down

0 comments on commit 5125927

Please sign in to comment.