diff options
author | Mateusz Grzonka <mateusz.grzonka@intel.com> | 2022-06-13 11:59:34 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2022-06-14 16:41:42 +0200 |
commit | 626bc45396c4959f2c4685c2faa7c4f553f4efdf (patch) | |
tree | 44cea41771402fc64ffd2280e95d786d64ed3b1b /Assemble.c | |
parent | Mdmonitor: Improve logging method (diff) | |
download | mdadm-626bc45396c4959f2c4685c2faa7c4f553f4efdf.tar.xz mdadm-626bc45396c4959f2c4685c2faa7c4f553f4efdf.zip |
Fix possible NULL ptr dereferences and memory leaks
In Assemble there was a NULL check for sra variable,
which effectively didn't stop the execution in every case.
That might have resulted in a NULL pointer dereference.
Also in super-ddf, mu variable was set to NULL for some condition,
and then immidiately dereferenced.
Additionally some memory wasn't freed as well.
Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'Assemble.c')
-rw-r--r-- | Assemble.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -1982,7 +1982,12 @@ int assemble_container_content(struct supertype *st, int mdfd, } sra = sysfs_read(mdfd, NULL, GET_VERSION|GET_DEVS); - if (sra == NULL || strcmp(sra->text_version, content->text_version) != 0) { + if (sra == NULL) { + pr_err("Failed to read sysfs parameters\n"); + return 1; + } + + if (strcmp(sra->text_version, content->text_version) != 0) { if (content->array.major_version == -1 && content->array.minor_version == -2 && c->readonly && |