summaryrefslogtreecommitdiffstats
path: root/super1.c
diff options
context:
space:
mode:
authorMateusz Kusiak <mateusz.kusiak@intel.com>2024-02-20 11:56:11 +0100
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-02-23 12:44:12 +0100
commit7ccf947eb595c1bb729c32ba18ce171dada76a68 (patch)
treea037dcd2bf16c2af2c12a2a3650377ebe5117042 /super1.c
parentGrow: remove dead condition in Grow_reshape() (diff)
downloadmdadm-7ccf947eb595c1bb729c32ba18ce171dada76a68.tar.xz
mdadm-7ccf947eb595c1bb729c32ba18ce171dada76a68.zip
super1: check fd before passing to get_dev_size() in add_to_super1()
Check if file descriptor is valid before passing it to get_dev_size() in add_to_super(). Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Diffstat (limited to 'super1.c')
-rw-r--r--super1.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/super1.c b/super1.c
index 871d19f0..5439b7bb 100644
--- a/super1.c
+++ b/super1.c
@@ -1752,7 +1752,10 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
di->devname = devname;
di->disk = *dk;
di->data_offset = data_offset;
- get_dev_size(fd, NULL, &di->dev_size);
+
+ if (is_fd_valid(fd))
+ get_dev_size(fd, NULL, &di->dev_size);
+
di->next = NULL;
*dip = di;