misc: open-dice: Fix spurious lockdep warning
authorWill Deacon <will@kernel.org>
Fri, 26 Jan 2024 15:24:10 +0000 (15:24 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Jan 2024 00:20:54 +0000 (16:20 -0800)
When probing the open-dice driver with PROVE_LOCKING=y, lockdep
complains that the mutex in 'drvdata->lock' has a non-static key:

 | INFO: trying to register non-static key.
 | The code is fine but needs lockdep annotation, or maybe
 | you didn't initialize this object before use?
 | turning off the locking correctness validator.

Fix the problem by initialising the mutex memory with mutex_init()
instead of __MUTEX_INITIALIZER().

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David Brazdil <dbrazdil@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20240126152410.10148-1-will@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/open-dice.c

index 8aea2d070a40c23e0a0ed9495d8039f9fa6804ac..d279a4f195e2a343a8332d25c25e85a89b6ac88f 100644 (file)
@@ -140,7 +140,6 @@ static int __init open_dice_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        *drvdata = (struct open_dice_drvdata){
-               .lock = __MUTEX_INITIALIZER(drvdata->lock),
                .rmem = rmem,
                .misc = (struct miscdevice){
                        .parent = dev,
@@ -150,6 +149,7 @@ static int __init open_dice_probe(struct platform_device *pdev)
                        .mode   = 0600,
                },
        };
+       mutex_init(&drvdata->lock);
 
        /* Index overflow check not needed, misc_register() will fail. */
        snprintf(drvdata->name, sizeof(drvdata->name), DRIVER_NAME"%u", dev_idx++);