mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
drm/amd/amdxcp: use kasprintf for XCP platform device names
Replace the fixed stack buffer with kasprintf() so platform device names are always fully formatted. Signed-off-by: Candice Li <candice.li@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
05465e2a13
commit
79a9f51ab9
|
|
@ -25,6 +25,7 @@
|
|||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include <drm/drm_drv.h>
|
||||
|
||||
|
|
@ -52,7 +53,7 @@ int amdgpu_xcp_drm_dev_alloc(struct drm_device **ddev)
|
|||
{
|
||||
struct platform_device *pdev;
|
||||
struct xcp_device *pxcp_dev;
|
||||
char dev_name[20];
|
||||
char *dev_name;
|
||||
int ret, i;
|
||||
|
||||
guard(mutex)(&xcp_mutex);
|
||||
|
|
@ -68,8 +69,12 @@ int amdgpu_xcp_drm_dev_alloc(struct drm_device **ddev)
|
|||
if (i >= MAX_XCP_PLATFORM_DEVICE)
|
||||
return -ENODEV;
|
||||
|
||||
snprintf(dev_name, sizeof(dev_name), "amdgpu_xcp_%d", i);
|
||||
dev_name = kasprintf(GFP_KERNEL, "amdgpu_xcp_%d", i);
|
||||
if (!dev_name)
|
||||
return -ENOMEM;
|
||||
|
||||
pdev = platform_device_register_simple(dev_name, -1, NULL, 0);
|
||||
kfree(dev_name);
|
||||
if (IS_ERR(pdev))
|
||||
return PTR_ERR(pdev);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user