]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mdesc: fix a missing-check bug in get_vdev_port_node_info()
authorGen Zhang <blackgod016574@gmail.com>
Fri, 31 May 2019 01:24:18 +0000 (09:24 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Jun 2019 03:35:57 +0000 (11:35 +0800)
[ Upstream commit 80caf43549e7e41a695c6d1e11066286538b336f ]

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.

Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/sparc/kernel/mdesc.c

index 39a2503fa3e18e8816dde7078c43dc5c5d509b5e..51028abe5e9038a127a39f5473049704120b66c6 100644 (file)
@@ -357,6 +357,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;