File 0014-Manage-Manage_add-Fix-potential-NULL-pointer-derefer.patch of Package mdadm.7129
From 2a1990c0f4bbb00920fafe7c8eec1b8837595d48 Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Date: Mon, 7 Mar 2016 11:49:03 -0500
Subject: [PATCH 235/359] Manage: Manage_add(): Fix potential NULL pointer
dereference
References: bsc#1081910
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>
Signed-off-by: Coly Li <colyli@suse.de>
---
Manage.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Manage.c b/Manage.c
index 414373f..a812ba0 100644
--- a/Manage.c
+++ b/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);
--
2.16.1