]> Git Repo - J-linux.git/commitdiff
soundwire: debugfs: simplify with cleanup.h
authorKrzysztof Kozlowski <[email protected]>
Wed, 3 Jul 2024 10:16:01 +0000 (12:16 +0200)
committerVinod Koul <[email protected]>
Tue, 9 Jul 2024 13:42:49 +0000 (19:12 +0530)
Allocate the memory with scoped/cleanup.h to reduce error handling and
make the code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Vinod Koul <[email protected]>
drivers/soundwire/debugfs.c

index 6d253d69871d900108952f11bb31ce283d9ae33d..c30f571934ee2e84ff4387833c60dc7b42a2b843 100644 (file)
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 // Copyright(c) 2017-2019 Intel Corporation.
 
+#include <linux/cleanup.h>
 #include <linux/device.h>
 #include <linux/debugfs.h>
 #include <linux/firmware.h>
@@ -49,18 +50,16 @@ static ssize_t sdw_sprintf(struct sdw_slave *slave,
 static int sdw_slave_reg_show(struct seq_file *s_file, void *data)
 {
        struct sdw_slave *slave = s_file->private;
-       char *buf;
        ssize_t ret;
        int i, j;
 
-       buf = kzalloc(RD_BUF, GFP_KERNEL);
+       char *buf __free(kfree) = kzalloc(RD_BUF, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 
        ret = pm_runtime_get_sync(&slave->dev);
        if (ret < 0 && ret != -EACCES) {
                pm_runtime_put_noidle(&slave->dev);
-               kfree(buf);
                return ret;
        }
 
@@ -132,8 +131,6 @@ static int sdw_slave_reg_show(struct seq_file *s_file, void *data)
        pm_runtime_mark_last_busy(&slave->dev);
        pm_runtime_put(&slave->dev);
 
-       kfree(buf);
-
        return 0;
 }
 DEFINE_SHOW_ATTRIBUTE(sdw_slave_reg);
This page took 0.044478 seconds and 4 git commands to generate.