Skip to content

Commit 01dd825

Browse files
krzkandersson
authored andcommitted
soc: qcom: mdt_loader: simplify with cleanup.h
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: Bjorn Andersson <[email protected]>
1 parent 04e60d7 commit 01dd825

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/soc/qcom/mdt_loader.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
88
*/
99

10+
#include <linux/cleanup.h>
1011
#include <linux/device.h>
1112
#include <linux/elf.h>
1213
#include <linux/firmware.h>
@@ -37,13 +38,12 @@ static ssize_t mdt_load_split_segment(void *ptr, const struct elf32_phdr *phdrs,
3738
{
3839
const struct elf32_phdr *phdr = &phdrs[segment];
3940
const struct firmware *seg_fw;
40-
char *seg_name;
4141
ssize_t ret;
4242

4343
if (strlen(fw_name) < 4)
4444
return -EINVAL;
4545

46-
seg_name = kstrdup(fw_name, GFP_KERNEL);
46+
char *seg_name __free(kfree) = kstrdup(fw_name, GFP_KERNEL);
4747
if (!seg_name)
4848
return -ENOMEM;
4949

@@ -52,7 +52,6 @@ static ssize_t mdt_load_split_segment(void *ptr, const struct elf32_phdr *phdrs,
5252
ptr, phdr->p_filesz);
5353
if (ret) {
5454
dev_err(dev, "error %zd loading %s\n", ret, seg_name);
55-
kfree(seg_name);
5655
return ret;
5756
}
5857

@@ -64,7 +63,6 @@ static ssize_t mdt_load_split_segment(void *ptr, const struct elf32_phdr *phdrs,
6463
}
6564

6665
release_firmware(seg_fw);
67-
kfree(seg_name);
6866

6967
return ret;
7068
}

0 commit comments

Comments
 (0)