Skip to content

Commit 572d8fd

Browse files
GustavoARSilvaairlied
authored andcommitted
char: amd64-agp: Use 64-bit arithmetic instead of 32-bit
Cast *tmp* and *nb_base* to u64 in order to give the compiler complete information about the proper arithmetic to use. Notice that such variables are used in contexts that expect expressions of type u64 (64 bits, unsigned) and the following expressions are currently being evaluated using 32-bit arithmetic: tmp << 25 nb_base << 25 Addresses-Coverity-ID: 200586 ("Unintentional integer overflow") Addresses-Coverity-ID: 200587 ("Unintentional integer overflow") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 8fb8876 commit 572d8fd

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/char/agp/amd64-agp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static u64 amd64_configure(struct pci_dev *hammer, u64 gatt_table)
156156

157157
/* Address to map to */
158158
pci_read_config_dword(hammer, AMD64_GARTAPERTUREBASE, &tmp);
159-
aperturebase = tmp << 25;
159+
aperturebase = (u64)tmp << 25;
160160
aper_base = (aperturebase & PCI_BASE_ADDRESS_MEM_MASK);
161161

162162
enable_gart_translation(hammer, gatt_table);
@@ -277,7 +277,7 @@ static int fix_northbridge(struct pci_dev *nb, struct pci_dev *agp, u16 cap)
277277
pci_read_config_dword(nb, AMD64_GARTAPERTURECTL, &nb_order);
278278
nb_order = (nb_order >> 1) & 7;
279279
pci_read_config_dword(nb, AMD64_GARTAPERTUREBASE, &nb_base);
280-
nb_aper = nb_base << 25;
280+
nb_aper = (u64)nb_base << 25;
281281

282282
/* Northbridge seems to contain crap. Try the AGP bridge. */
283283

0 commit comments

Comments
 (0)