]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
amd-xgbe: Check for successful buffer allocation before use
authorTom Lendacky <thomas.lendacky@amd.com>
Mon, 5 Oct 2015 15:51:03 +0000 (10:51 -0500)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Oct 2015 06:30:51 +0000 (23:30 -0700)
The kasprintf function can return NULL if the allocation fails. Check for
successful allocation before attempting to use the returned buffer.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c

index 66137ffea3f89666e66071832b3d626f9ef0abba..96f485ab612e679dc7065b1e214cb9d73c690d43 100644 (file)
@@ -327,6 +327,9 @@ void xgbe_debugfs_init(struct xgbe_prv_data *pdata)
        pdata->debugfs_xpcs_reg = 0;
 
        buf = kasprintf(GFP_KERNEL, "amd-xgbe-%s", pdata->netdev->name);
+       if (!buf)
+               return;
+
        pdata->xgbe_debugfs = debugfs_create_dir(buf, NULL);
        if (!pdata->xgbe_debugfs) {
                netdev_err(pdata->netdev, "debugfs_create_dir failed\n");