block: fix invalid free condition

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-07-19 17:48:34 -04:00
commit 1a8061e3b3

View file

@ -22,11 +22,11 @@ int block_device_register(char *name, size_t lba_start, struct block_ops *ops, s
strncpy(ret->name, name, sizeof(ret->name) - 1);
*out = ret;
memcpy(ops, &ret->ops, sizeof(struct block_ops));
memcpy(&ret->ops, ops, sizeof(struct block_ops));
dirent_t *dirent;
int res = devfs_insert_device_blk(ret->name, ret, &dirent);
(void)res;
(void)res;
return 0;
}
@ -39,7 +39,7 @@ int block_check_partitions(struct block_device *bdev)
int ret = 0;
if (block_has_gpt_header(bdev)) {
struct gpt_partition *descs;
struct gpt_partition *descs = NULL;
int n_partitions = gpt_parse_partitions(bdev, &descs);
for (int i = 0; i < n_partitions; i++) {
@ -56,7 +56,7 @@ int block_check_partitions(struct block_device *bdev)
krdy("registered block device /dev/%s\n", blkdev->name);
}
if (n_partitions)
if (descs)
kfree(descs);
}