diff options
author | Aaro Koskinen <aaro.koskinen@iki.fi> | 2012-09-11 17:44:38 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-12 12:47:09 -0400 |
commit | 6b2a7e0c9bcc0a4df385d1ef8fe5109cea0260e2 (patch) | |
tree | 8d657fa38cfd3a037d0793a3cf5659f0085e18e9 | |
parent | a09f347c6cc0b2821557d1346c4733cc78a79ffa (diff) |
staging: xgifb: prevent video RAM size exceeding PCI window size
Add a sanity check for the video RAM size. It should fit into the
PCI window.
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/xgifb/XGI_main_26.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index ba6c3475a517..98b8b096d58c 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c | |||
@@ -1700,6 +1700,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, | |||
1700 | struct fb_info *fb_info; | 1700 | struct fb_info *fb_info; |
1701 | struct xgifb_video_info *xgifb_info; | 1701 | struct xgifb_video_info *xgifb_info; |
1702 | struct xgi_hw_device_info *hw_info; | 1702 | struct xgi_hw_device_info *hw_info; |
1703 | unsigned long video_size_max; | ||
1703 | 1704 | ||
1704 | fb_info = framebuffer_alloc(sizeof(*xgifb_info), &pdev->dev); | 1705 | fb_info = framebuffer_alloc(sizeof(*xgifb_info), &pdev->dev); |
1705 | if (!fb_info) | 1706 | if (!fb_info) |
@@ -1720,6 +1721,7 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, | |||
1720 | xgifb_info->subsysvendor = pdev->subsystem_vendor; | 1721 | xgifb_info->subsysvendor = pdev->subsystem_vendor; |
1721 | xgifb_info->subsysdevice = pdev->subsystem_device; | 1722 | xgifb_info->subsysdevice = pdev->subsystem_device; |
1722 | 1723 | ||
1724 | video_size_max = pci_resource_len(pdev, 0); | ||
1723 | xgifb_info->video_base = pci_resource_start(pdev, 0); | 1725 | xgifb_info->video_base = pci_resource_start(pdev, 0); |
1724 | xgifb_info->mmio_base = pci_resource_start(pdev, 1); | 1726 | xgifb_info->mmio_base = pci_resource_start(pdev, 1); |
1725 | xgifb_info->mmio_size = pci_resource_len(pdev, 1); | 1727 | xgifb_info->mmio_size = pci_resource_len(pdev, 1); |
@@ -1780,6 +1782,8 @@ static int __devinit xgifb_probe(struct pci_dev *pdev, | |||
1780 | "Fatal error: Unable to determine RAM size.\n"); | 1782 | "Fatal error: Unable to determine RAM size.\n"); |
1781 | ret = -ENODEV; | 1783 | ret = -ENODEV; |
1782 | goto error_disable; | 1784 | goto error_disable; |
1785 | } else if (xgifb_info->video_size > video_size_max) { | ||
1786 | xgifb_info->video_size = video_size_max; | ||
1783 | } | 1787 | } |
1784 | 1788 | ||
1785 | /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */ | 1789 | /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE */ |