Skip to content

Commit cf92bb7

Browse files
Mikhail Kobukdakr
authored andcommitted
drm: nv04: Fix out of bounds access
When Output Resource (dcb->or) value is assigned in fabricate_dcb_output(), there may be out of bounds access to dac_users array in case dcb->or is zero because ffs(dcb->or) is used as index there. The 'or' argument of fabricate_dcb_output() must be interpreted as a number of bit to set, not value. Utilize macros from 'enum nouveau_or' in calls instead of hardcoding. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 2e5702a ("drm/nouveau: fabricate DCB encoder table for iMac G4") Fixes: 670820c ("drm/nouveau: Workaround incorrect DCB entry on a GeForce3 Ti 200.") Signed-off-by: Mikhail Kobuk <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent fff1386 commit cf92bb7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/gpu/drm/nouveau/nouveau_bios.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424

2525
#include "nouveau_drv.h"
26+
#include "nouveau_bios.h"
2627
#include "nouveau_reg.h"
2728
#include "dispnv04/hw.h"
2829
#include "nouveau_encoder.h"
@@ -1677,7 +1678,7 @@ apply_dcb_encoder_quirks(struct drm_device *dev, int idx, u32 *conn, u32 *conf)
16771678
*/
16781679
if (nv_match_device(dev, 0x0201, 0x1462, 0x8851)) {
16791680
if (*conn == 0xf2005014 && *conf == 0xffffffff) {
1680-
fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 1, 1, 1);
1681+
fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 1, 1, DCB_OUTPUT_B);
16811682
return false;
16821683
}
16831684
}
@@ -1763,26 +1764,26 @@ fabricate_dcb_encoder_table(struct drm_device *dev, struct nvbios *bios)
17631764
#ifdef __powerpc__
17641765
/* Apple iMac G4 NV17 */
17651766
if (of_machine_is_compatible("PowerMac4,5")) {
1766-
fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 0, all_heads, 1);
1767-
fabricate_dcb_output(dcb, DCB_OUTPUT_ANALOG, 1, all_heads, 2);
1767+
fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS, 0, all_heads, DCB_OUTPUT_B);
1768+
fabricate_dcb_output(dcb, DCB_OUTPUT_ANALOG, 1, all_heads, DCB_OUTPUT_C);
17681769
return;
17691770
}
17701771
#endif
17711772

17721773
/* Make up some sane defaults */
17731774
fabricate_dcb_output(dcb, DCB_OUTPUT_ANALOG,
1774-
bios->legacy.i2c_indices.crt, 1, 1);
1775+
bios->legacy.i2c_indices.crt, 1, DCB_OUTPUT_B);
17751776

17761777
if (nv04_tv_identify(dev, bios->legacy.i2c_indices.tv) >= 0)
17771778
fabricate_dcb_output(dcb, DCB_OUTPUT_TV,
17781779
bios->legacy.i2c_indices.tv,
1779-
all_heads, 0);
1780+
all_heads, DCB_OUTPUT_A);
17801781

17811782
else if (bios->tmds.output0_script_ptr ||
17821783
bios->tmds.output1_script_ptr)
17831784
fabricate_dcb_output(dcb, DCB_OUTPUT_TMDS,
17841785
bios->legacy.i2c_indices.panel,
1785-
all_heads, 1);
1786+
all_heads, DCB_OUTPUT_B);
17861787
}
17871788

17881789
static int

0 commit comments

Comments
 (0)