Skip to contentSkip to conversation

mdesc: fix a missing-check bug in get_vdev_port_node_info()

PATCH Applied Gen Zhang 2 participants 2 messages May 31, 2019 – Jun 3, 2019 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore

Gen Zhang

author
#0 lore raw

PATCH 1/1 mdesc: fix a missing-check bug in get_vdev_port_node_info()

In get_vdev_port_node_info(), 'node_info->vdev_port.name' is allcoated by kstrdup_const(), and it returns NULL when fails. So 'node_info->vdev_port.name' should be checked.

---

arch/sparc/kernel/mdesc.c +2 -0
index 9a26b44..8e645dd 100644
@@ -356,6 +356,8 @@ static int get_vdev_port_node_info(struct mdesc_handle *md, u64 node,
 
 	node_info->vdev_port.id = *idp;
 	node_info->vdev_port.name = kstrdup_const(name, GFP_KERNEL);
+	if (!node_info->vdev_port.name)
+		return -1;
 	node_info->vdev_port.parent_cfg_hdl = *parent_cfg_hdlp;
 
 	return 0;

---

maintainer Applied
#1 lore raw

From: Gen Zhang <[email protected]>
Date: Fri, 31 May 2019 09:24:18 +0800

Quoted 5 lines

In get_vdev_port_node_info(), 'node_info->vdev_port.name' is allcoated by kstrdup_const(), and it returns NULL when fails. So 'node_info->vdev_port.name' should be checked.

Applied, thanks.