diff options
Diffstat (limited to 'drivers/gpu/drm/drm_pci.c')
-rw-r--r-- | drivers/gpu/drm/drm_pci.c | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c index 020cfd934854..8efea6b4602b 100644 --- a/drivers/gpu/drm/drm_pci.c +++ b/drivers/gpu/drm/drm_pci.c | |||
@@ -129,31 +129,17 @@ static int drm_get_pci_domain(struct drm_device *dev) | |||
129 | 129 | ||
130 | static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) | 130 | static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) |
131 | { | 131 | { |
132 | int len, ret; | 132 | master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d", |
133 | master->unique_len = 40; | 133 | drm_get_pci_domain(dev), |
134 | master->unique_size = master->unique_len; | 134 | dev->pdev->bus->number, |
135 | master->unique = kmalloc(master->unique_size, GFP_KERNEL); | 135 | PCI_SLOT(dev->pdev->devfn), |
136 | if (master->unique == NULL) | 136 | PCI_FUNC(dev->pdev->devfn)); |
137 | if (!master->unique) | ||
137 | return -ENOMEM; | 138 | return -ENOMEM; |
138 | 139 | ||
139 | 140 | master->unique_len = strlen(master->unique); | |
140 | len = snprintf(master->unique, master->unique_len, | 141 | master->unique_size = master->unique_len + 1; |
141 | "pci:%04x:%02x:%02x.%d", | ||
142 | drm_get_pci_domain(dev), | ||
143 | dev->pdev->bus->number, | ||
144 | PCI_SLOT(dev->pdev->devfn), | ||
145 | PCI_FUNC(dev->pdev->devfn)); | ||
146 | |||
147 | if (len >= master->unique_len) { | ||
148 | DRM_ERROR("buffer overflow"); | ||
149 | ret = -EINVAL; | ||
150 | goto err; | ||
151 | } else | ||
152 | master->unique_len = len; | ||
153 | |||
154 | return 0; | 142 | return 0; |
155 | err: | ||
156 | return ret; | ||
157 | } | 143 | } |
158 | 144 | ||
159 | int drm_pci_set_unique(struct drm_device *dev, | 145 | int drm_pci_set_unique(struct drm_device *dev, |