diff options
author | Anna Sztukowska <anna.sztukowska@intel.com> | 2024-07-24 11:46:57 +0200 |
---|---|---|
committer | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-08-05 11:44:15 +0200 |
commit | 483ff037f1036f5f604e085cf76097a87e2be348 (patch) | |
tree | 2c98ab87f8675c5e64aa84c9fcfdc6b052ee7a28 | |
parent | policy.c: Fix check_return issue in Write_rules() (diff) | |
download | mdadm-483ff037f1036f5f604e085cf76097a87e2be348.tar.xz mdadm-483ff037f1036f5f604e085cf76097a87e2be348.zip |
super-gpt.c: Fix check_return issue in load_gpt()
Fix check_return issue in load_gpt() reported by SAST analysis in
super-gpt.c.
Signed-off-by: Anna Sztukowska <anna.sztukowska@intel.com>
-rw-r--r-- | super-gpt.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/super-gpt.c b/super-gpt.c index a1e9aa9d..ec3cf53f 100644 --- a/super-gpt.c +++ b/super-gpt.c @@ -105,7 +105,8 @@ static int load_gpt(struct supertype *st, int fd, char *devname) return 1; } /* Set offset to second block (GPT header) */ - lseek(fd, sector_size, SEEK_SET); + if (lseek(fd, sector_size, SEEK_SET) == -1L) + goto no_read; /* Seem to have GPT, load the header */ gpt_head = (struct GPT*)(super+1); if (read(fd, gpt_head, sizeof(*gpt_head)) != sizeof(*gpt_head)) @@ -118,7 +119,8 @@ static int load_gpt(struct supertype *st, int fd, char *devname) to_read = __le32_to_cpu(gpt_head->part_cnt) * sizeof(struct GPT_part_entry); to_read = ((to_read+511)/512) * 512; /* Set offset to third block (GPT entries) */ - lseek(fd, sector_size*2, SEEK_SET); + if (lseek(fd, sector_size * 2, SEEK_SET) == -1L) + goto no_read; if (read(fd, gpt_head+1, to_read) != to_read) goto no_read; |