File: kernel_ioremap_check_null.patch

package info (click to toggle)
mstflint 4.31.0%2B1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 37,200 kB
  • sloc: ansic: 205,509; cpp: 103,810; ada: 15,143; sh: 11,406; python: 8,039; makefile: 1,413
file content (30 lines) | stat: -rw-r--r-- 1,146 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From: Tzafrir Cohen <nvidia@cohens.org.il>
Subject: Test return of ioremap with non-NULL

Don't consider the result of ioremap a pointer that can include an errno
(was that the rationale?).

Avoids an error of considering a pointer as an int.

diff --git a/kernel/mst_main.c b/kernel/mst_main.c
index 06d6f89..d39a4e6 100644
--- a/kernel/mst_main.c
+++ b/kernel/mst_main.c
@@ -1502,7 +1502,7 @@ static int mst_ioctl(struct inode* inode, struct file* file, unsigned int opcode
 
         dev->hw_addr = ioremap(resource_start, MST_MEMORY_SIZE);
 
-        if (dev->hw_addr <= 0) {
+        if (!dev->hw_addr) {
             mst_err("could not map device memory\n");
             res = -EFAULT;
             goto fin;
@@ -1780,7 +1780,7 @@ static struct mst_dev_data* mst_device_create(enum dev_type type, struct pci_dev
         dev->data_reg = 0;     /* invalid */
         dev->bar = 0;
         dev->hw_addr = ioremap(pci_resource_start(pdev, dev->bar), MST_MEMORY_SIZE);
-        if (dev->hw_addr <= 0) {
+        if (!dev->hw_addr) {
             mst_err("could not map device memory, BAR: %x\n", dev->bar);
             goto out;
         }