Skip to contentSkip to conversation

ocfs2:fix potential Null Ptr Dereference

PATCH In review Yizhuo 2 participants 2 messages Oct 10, 2019 OCFS2

lore
Share & tools
lore

Yizhuo

author
#0 lore raw

PATCH 1/1 ocfs2:fix potential Null Ptr Dereference

Inside function o2hb_region_blocks_store(), to_o2hb_region() could return NULL but there's no check before its dereference, which is potentially unsafe.

---
 fs/ocfs2/cluster/heartbeat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/cluster/heartbeat.c +1 -1
index a368350d4c27..93f2b540f245 100644
@@ -1628,7 +1628,7 @@ static ssize_t o2hb_region_blocks_store(struct config_item *item,
 	unsigned long tmp;
 	char *p = (char *)page;
 
-	if (reg->hr_bdev)
+	if (!reg || reg->hr_bdev)
 		return -EINVAL;
 
 	tmp = simple_strtoul(p, &p, 0);
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 3 lines · Yizhuo

Inside function o2hb_region_blocks_store(), to_o2hb_region() could return NULL but there's no check before its dereference, which is potentially unsafe.

As I described before, this won't happen IMHO.
configfs item is initialized after loading module, so region should be valid here.

Thanks,
Joseph

Quoted 20 lines
---
 fs/ocfs2/cluster/heartbeat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/cluster/heartbeat.c +1 -1
index a368350d4c27..93f2b540f245 100644
@@ -1628,7 +1628,7 @@ static ssize_t o2hb_region_blocks_store(struct config_item *item,
 	unsigned long tmp;
 	char *p = (char *)page;
 
-	if (reg->hr_bdev)
+	if (!reg || reg->hr_bdev)
 		return -EINVAL;
 
 	tmp = simple_strtoul(p, &p, 0);