Manage: Manage_add(): Fix potential NULL pointer dereference
sysfs_read() may return NULL, so we should check the validity of the pointer before dereferencing it. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
This commit is contained in:
parent
30e19bf805
commit
2a1990c0f4
4
Manage.c
4
Manage.c
|
@ -938,6 +938,10 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
|
|||
struct mdinfo *mdp;
|
||||
|
||||
mdp = sysfs_read(fd, NULL, GET_ARRAY_STATE);
|
||||
if (!mdp) {
|
||||
pr_err("%s unable to read array state.\n", devname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strncmp(mdp->sysfs_array_state, "readonly", 8) != 0) {
|
||||
pr_err("%s is not readonly, cannot add journal.\n", devname);
|
||||
|
|
Loading…
Reference in New Issue