Browse Source

amd-xgbe: Check for successful buffer allocation before use

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>
Tom Lendacky 9 years ago
parent
commit
855591d2f7
1 changed files with 3 additions and 0 deletions
  1. 3 0
      drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c

+ 3 - 0
drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c

@@ -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");