Commit b1dda997 authored by Laurent Pinchart's avatar Laurent Pinchart

drm: Use a const drm_driver for legacy PCI devices

Now that the legacy PCI support code doesn't need to write to the
drm_driver structure, it can be treated as const through the whole DRM
core, unconditionally. This allows declaring the structure as const in
all drivers, removing one possible attack vector.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 8dbe1b4a
......@@ -589,11 +589,7 @@ static int drm_dev_init(struct drm_device *dev,
kref_init(&dev->ref);
dev->dev = get_device(parent);
#ifdef CONFIG_DRM_LEGACY
dev->driver = (struct drm_driver *)driver;
#else
dev->driver = driver;
#endif
INIT_LIST_HEAD(&dev->managed.resources);
spin_lock_init(&dev->managed.lock);
......
......@@ -201,7 +201,7 @@ static void drm_pci_agp_init(struct drm_device *dev)
static int drm_get_pci_dev(struct pci_dev *pdev,
const struct pci_device_id *ent,
struct drm_driver *driver)
const struct drm_driver *driver)
{
struct drm_device *dev;
int ret;
......@@ -255,7 +255,8 @@ static int drm_get_pci_dev(struct pci_dev *pdev,
*
* Return: 0 on success or a negative error code on failure.
*/
int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
int drm_legacy_pci_init(const struct drm_driver *driver,
struct pci_driver *pdriver)
{
struct pci_dev *pdev = NULL;
const struct pci_device_id *pid;
......@@ -300,7 +301,8 @@ EXPORT_SYMBOL(drm_legacy_pci_init);
* Unregister a DRM driver shadow-attached through drm_legacy_pci_init(). This
* is deprecated and only used by dri1 drivers.
*/
void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver)
void drm_legacy_pci_exit(const struct drm_driver *driver,
struct pci_driver *pdriver)
{
struct drm_device *dev, *tmp;
......
......@@ -76,11 +76,7 @@ struct drm_device {
} managed;
/** @driver: DRM driver managing the device */
#ifdef CONFIG_DRM_LEGACY
struct drm_driver *driver;
#else
const struct drm_driver *driver;
#endif
/**
* @dev_private:
......
......@@ -198,8 +198,10 @@ struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
size_t align);
void drm_pci_free(struct drm_device *dev, struct drm_dma_handle *dmah);
int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
int drm_legacy_pci_init(const struct drm_driver *driver,
struct pci_driver *pdriver);
void drm_legacy_pci_exit(const struct drm_driver *driver,
struct pci_driver *pdriver);
#else
......@@ -214,13 +216,13 @@ static inline void drm_pci_free(struct drm_device *dev,
{
}
static inline int drm_legacy_pci_init(struct drm_driver *driver,
static inline int drm_legacy_pci_init(const struct drm_driver *driver,
struct pci_driver *pdriver)
{
return -EINVAL;
}
static inline void drm_legacy_pci_exit(struct drm_driver *driver,
static inline void drm_legacy_pci_exit(const struct drm_driver *driver,
struct pci_driver *pdriver)
{
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment