lkml.org 
[lkml]   [2015]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.1 170/267] tpm: Fix initialization of the cdev
    Date
    4.1-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>

    commit ba0ef85479c46a2ab354c2220bdb6152f7f4baf3 upstream.

    When a cdev is contained in a dynamic structure the cdev parent kobj
    should be set to the kobj that controls the lifetime of the enclosing
    structure. In TPM's case this is the embedded struct device.

    Also, cdev_init 0's the whole structure, so all sets must be after,
    not before. This fixes module ref counting and cdev.

    Fixes: 313d21eeab92 ("tpm: device class for tpm")
    Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
    Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
    Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
    Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/char/tpm/tpm-chip.c | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    --- a/drivers/char/tpm/tpm-chip.c
    +++ b/drivers/char/tpm/tpm-chip.c
    @@ -129,8 +129,9 @@ struct tpm_chip *tpmm_chip_alloc(struct

    device_initialize(&chip->dev);

    - chip->cdev.owner = chip->pdev->driver->owner;
    cdev_init(&chip->cdev, &tpm_fops);
    + chip->cdev.owner = chip->pdev->driver->owner;
    + chip->cdev.kobj.parent = &chip->dev.kobj;

    return chip;
    }



    \
     
     \ /
      Last update: 2015-07-31 23:41    [W:4.162 / U:0.288 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site