[PATCH] fs: exfat: Remove unused label code

Andrew Goodbody andrew.goodbody at linaro.org
Thu Jul 17 14:04:58 CEST 2025


Smatch reported a possible buffer overflow in exfat_set_label but it
turns out that this code is unused so just remove the function as well
as exfat_get_label that is also unused and the helper static find_label.

Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
---
 fs/exfat/exfat.h |  2 --
 fs/exfat/node.c  | 54 ------------------------------------------------------
 2 files changed, 56 deletions(-)

diff --git a/fs/exfat/exfat.h b/fs/exfat/exfat.h
index ca6f22b9d58..19d6a70c48c 100644
--- a/fs/exfat/exfat.h
+++ b/fs/exfat/exfat.h
@@ -237,8 +237,6 @@ int exfat_rename(struct exfat* ef, const char* old_path, const char* new_path);
 void exfat_utimes(struct exfat_node* node, const struct timespec tv[2]);
 void exfat_update_atime(struct exfat_node* node);
 void exfat_update_mtime(struct exfat_node* node);
-const char* exfat_get_label(struct exfat* ef);
-int exfat_set_label(struct exfat* ef, const char* label);
 
 int exfat_soil_super_block(const struct exfat* ef);
 int exfat_mount(struct exfat* ef, const char* spec, const char* options);
diff --git a/fs/exfat/node.c b/fs/exfat/node.c
index 88b1357189c..2e2fae7935f 100644
--- a/fs/exfat/node.c
+++ b/fs/exfat/node.c
@@ -1187,57 +1187,3 @@ void exfat_update_mtime(struct exfat_node* node)
 	node->mtime = time(NULL);
 	node->is_dirty = true;
 }
-
-const char* exfat_get_label(struct exfat* ef)
-{
-	return ef->label;
-}
-
-static int find_label(struct exfat* ef, off_t* offset)
-{
-	struct exfat_entry entry;
-	int rc;
-
-	for (*offset = 0; ; *offset += sizeof(entry))
-	{
-		rc = read_entries(ef, ef->root, &entry, 1, *offset);
-		if (rc != 0)
-			return rc;
-
-		if (entry.type == EXFAT_ENTRY_LABEL)
-			return 0;
-	}
-}
-
-int exfat_set_label(struct exfat* ef, const char* label)
-{
-	le16_t label_utf16[EXFAT_ENAME_MAX + 1];
-	int rc;
-	off_t offset;
-	struct exfat_entry_label entry;
-
-	memset(label_utf16, 0, sizeof(label_utf16));
-	rc = exfat_utf8_to_utf16(label_utf16, label, EXFAT_ENAME_MAX + 1,
-			strlen(label));
-	if (rc != 0)
-		return rc;
-
-	rc = find_label(ef, &offset);
-	if (rc == -ENOENT)
-		rc = find_slot(ef, ef->root, &offset, 1);
-	if (rc != 0)
-		return rc;
-
-	entry.type = EXFAT_ENTRY_LABEL;
-	entry.length = exfat_utf16_length(label_utf16);
-	memcpy(entry.name, label_utf16, sizeof(entry.name));
-	if (entry.length == 0)
-		entry.type ^= EXFAT_ENTRY_VALID;
-
-	rc = write_entries(ef, ef->root, (struct exfat_entry*) &entry, 1, offset);
-	if (rc != 0)
-		return rc;
-
-	strcpy(ef->label, label);
-	return 0;
-}

---
base-commit: 3b4604a40b9fd61b87e9d059fc56f04d36f1a380
change-id: 20250717-exfat_label-bf4af04ea293

Best regards,
-- 
Andrew Goodbody <andrew.goodbody at linaro.org>



More information about the U-Boot mailing list