Skip to content

Commit 4076ea2

Browse files
committed
drm/nouveau/disp: Fix nvif_outp_acquire_dp() argument size
Both Coverity and GCC with -Wstringop-overflow noticed that nvif_outp_acquire_dp() accidentally defined its second argument with 1 additional element: drivers/gpu/drm/nouveau/dispnv50/disp.c: In function 'nv50_pior_atomic_enable': drivers/gpu/drm/nouveau/dispnv50/disp.c:1813:17: error: 'nvif_outp_acquire_dp' accessing 16 bytes in a region of size 15 [-Werror=stringop-overflow=] 1813 | nvif_outp_acquire_dp(&nv_encoder->outp, nv_encoder->dp.dpcd, 0, 0, false, false); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/nouveau/dispnv50/disp.c:1813:17: note: referencing argument 2 of type 'u8[16]' {aka 'unsigned char[16]'} drivers/gpu/drm/nouveau/include/nvif/outp.h:24:5: note: in a call to function 'nvif_outp_acquire_dp' 24 | int nvif_outp_acquire_dp(struct nvif_outp *, u8 dpcd[16], | ^~~~~~~~~~~~~~~~~~~~ Avoid these warnings by defining the argument size using the matching define (DP_RECEIVER_CAP_SIZE, 15) instead of having it be a literal (and incorrect) value (16). Reported-by: coverity-bot <[email protected]> Addresses-Coverity-ID: 1527269 ("Memory - corruptions") Addresses-Coverity-ID: 1527268 ("Memory - corruptions") Link: https://lore.kernel.org/lkml/202211100848.FFBA2432@keescook/ Link: https://lore.kernel.org/lkml/202211100848.F4C2819BB@keescook/ Fixes: 8134437 ("drm/nouveau/disp: move DP link config into acquire") Reviewed-by: Lyude Paul <[email protected]> Cc: Ben Skeggs <[email protected]> Cc: Karol Herbst <[email protected]> Cc: David Airlie <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Dave Airlie <[email protected]> Cc: "Gustavo A. R. Silva" <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent eba7735 commit 4076ea2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

drivers/gpu/drm/nouveau/include/nvif/outp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define __NVIF_OUTP_H__
44
#include <nvif/object.h>
55
#include <nvif/if0012.h>
6+
#include <drm/display/drm_dp.h>
67
struct nvif_disp;
78

89
struct nvif_outp {
@@ -21,7 +22,7 @@ int nvif_outp_acquire_rgb_crt(struct nvif_outp *);
2122
int nvif_outp_acquire_tmds(struct nvif_outp *, int head,
2223
bool hdmi, u8 max_ac_packet, u8 rekey, u8 scdc, bool hda);
2324
int nvif_outp_acquire_lvds(struct nvif_outp *, bool dual, bool bpc8);
24-
int nvif_outp_acquire_dp(struct nvif_outp *, u8 dpcd[16],
25+
int nvif_outp_acquire_dp(struct nvif_outp *outp, u8 dpcd[DP_RECEIVER_CAP_SIZE],
2526
int link_nr, int link_bw, bool hda, bool mst);
2627
void nvif_outp_release(struct nvif_outp *);
2728
int nvif_outp_infoframe(struct nvif_outp *, u8 type, struct nvif_outp_infoframe_v0 *, u32 size);

drivers/gpu/drm/nouveau/nvif/outp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ nvif_outp_acquire(struct nvif_outp *outp, u8 proto, struct nvif_outp_acquire_v0
127127
}
128128

129129
int
130-
nvif_outp_acquire_dp(struct nvif_outp *outp, u8 dpcd[16],
130+
nvif_outp_acquire_dp(struct nvif_outp *outp, u8 dpcd[DP_RECEIVER_CAP_SIZE],
131131
int link_nr, int link_bw, bool hda, bool mst)
132132
{
133133
struct nvif_outp_acquire_v0 args;

0 commit comments

Comments
 (0)