Skip to content

Commit 855591d

Browse files
tlendackydavem330
authored andcommitted
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>
1 parent 83ffe99 commit 855591d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ void xgbe_debugfs_init(struct xgbe_prv_data *pdata)
327327
pdata->debugfs_xpcs_reg = 0;
328328

329329
buf = kasprintf(GFP_KERNEL, "amd-xgbe-%s", pdata->netdev->name);
330+
if (!buf)
331+
return;
332+
330333
pdata->xgbe_debugfs = debugfs_create_dir(buf, NULL);
331334
if (!pdata->xgbe_debugfs) {
332335
netdev_err(pdata->netdev, "debugfs_create_dir failed\n");

0 commit comments

Comments
 (0)