]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
intel_th: Fix a double put_device() in error path
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Wed, 20 Nov 2019 13:08:04 +0000 (15:08 +0200)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:23:54 +0000 (14:23 -0300)
BugLink: https://bugs.launchpad.net/bugs/1856869
commit 512592779a337feb5905d8fcf9498dbf33672d4a upstream.

Commit a753bfcfdb1f ("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: a753bfcfdb1f ("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>
Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/hwtracing/intel_th/core.c

index 55922896d862686fbe64e9ea214f1d15413f1797..ebe992824b56def8fe95ecc953b1131dc188a5de 100644 (file)
@@ -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)
@@ -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) {