video: fbdev: sis: fix null ptr dereference
Subsystems (2)
PATCH 1/1 video: fbdev: sis: fix null ptr dereference
From: Tom Rix <[email protected]>
Clang static analysis reports this representative error
init.c:2501:18: warning: Array access (from variable 'queuedata') results
in a null pointer dereference
templ |= ((queuedata[i] & 0xc0) << 3);
This is the problem block of code
if(ModeNo > 0x13) {
...
if(SiS_Pr->ChipType = SIS_730) {
queuedata = &FQBQData730[0];
} else {
queuedata = &FQBQData[0];
}} else {
}
queuedata is not set in the else block
Reviewing the old code, the arrays FQBQData730 and FQBQData were used directly.
So hoist the setting of queuedata out of the if-else block.
--- drivers/video/fbdev/sis/init.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/video/fbdev/sis/init.c +5 -6
@@ -2428,6 +2428,11 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo, i =0 ; +if (SiS_Pr->ChipType =SIS_730 ) + queuedata = &FQBQData730[0 ]; +else + queuedata = &FQBQData[0 ]; +if (ModeNo >0x13 ) {/* Get VCLK */
@@ -2445,12 +2450,6 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo,/* Get half colordepth */ colorth = colortharray[(SiS_Pr->SiS_ModeType - ModeEGA)]; -if (SiS_Pr->ChipType =SIS_730 ) { - queuedata = &FQBQData730[0 ]; - }else { - queuedata = &FQBQData[0 ]; - } - do { templ = SiS_CalcDelay2(SiS_Pr, queuedata[i]) * VCLK * colorth;
Signature · 1 line
2.18.1
Bartlomiej Zolnierkiewicz
AppliedQuoted 23 lines · On 8/5/20 4:52 PM, [email protected] wrote:
From: Tom Rix <[email protected]>
Clang static analysis reports this representative error
init.c:2501:18: warning: Array access (from variable 'queuedata') results
in a null pointer dereferencetempl |= ((queuedata[i] & 0xc0) << 3);This is the problem block of code
if(ModeNo > 0x13) { ... if(SiS_Pr->ChipType = SIS_730) { queuedata = &FQBQData730[0]; } else { queuedata = &FQBQData[0]; } } else { }queuedata is not set in the else block
Quoted 8 lines
Reviewing the old code, the arrays FQBQData730 and FQBQData were used directly.
So hoist the setting of queuedata out of the if-else block.
Fixes 544393fe584d ("[PATCH] sisfb update")Signed-off-by Tom Rix <[email protected]>
Applied to drm-misc-next tree, thanks.
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Quoted 34 lines
--- drivers/video/fbdev/sis/init.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/video/fbdev/sis/init.c +5
-6@@ -2428,6 +2428,11 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo, i =0 ; +if (SiS_Pr->ChipType =SIS_730 ) + queuedata = &FQBQData730[0 ]; +else + queuedata = &FQBQData[0 ]; +if (ModeNo >0x13 ) {/* Get VCLK */ @@ -2445,12 +2450,6 @@ SiS_SetCRT1FIFO_630(struct SiS_Private *SiS_Pr, unsigned short ModeNo,/* Get half colordepth */ colorth = colortharray[(SiS_Pr->SiS_ModeType - ModeEGA)]; -if (SiS_Pr->ChipType =SIS_730 ) { - queuedata = &FQBQData730[0 ]; - }else { - queuedata = &FQBQData[0 ]; - } - do { templ = SiS_CalcDelay2(SiS_Pr, queuedata[i]) * VCLK * colorth;