diff options
author | Ian Moffett <ian@osmora.org> | 2025-08-15 03:40:17 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-08-15 03:40:17 -0400 |
commit | a578652c71b03bbdce45780cb271983ca2806c68 (patch) | |
tree | 725a607697d7806358458e37b4c08ea133224939 /sys | |
parent | 667cc7b8e130fa104a06e2fca93673015448f2c8 (diff) |
kernel: disk: Add disk limit enforcementsexpt
The number of disks registered within the system should not exceed the
DISK_MAX limit. Log an error and bail if that happens.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_disk.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/kern/kern_disk.c b/sys/kern/kern_disk.c index 1b16e4d..b956c02 100644 --- a/sys/kern/kern_disk.c +++ b/sys/kern/kern_disk.c @@ -239,6 +239,13 @@ disk_add(const char *name, dev_t dev, const struct bdevsw *bdev, int flags) /* Disk queue must be initialized */ check_diskq(); + /* There is a limit to how many can be added */ + if (disk_count >= DISK_MAX) { + pr_error("disk_add: disk limit %d/%d reached\n", + disk_count, DISK_MAX); + return -EAGAIN; + } + /* Is the disk name of correct length? */ name_len = strlen(name); if (name_len >= sizeof(dp->name) - 1) { |