[smatch stuff] xgifb: read outside array inxgifb_probe()?

Dan Carpenter error27 at gmail.com
Fri Aug 26 02:11:22 PDT 2011


Hi Aaro,

Can xgifb_mode_idx be set to -1 here?

drivers/staging/xgifb/XGI_main_26.c +2329 xgifb_probe(302)
	error: testing array offset 'xgifb_mode_idx' after use.

  2189   if (!XGIfb_GetXG21LVDSData()) {
  2190   	int m;
  2191          for (m = 0; m < sizeof(XGI21_LCDCapList)/sizeof(struct XGI21_LVDSCapStruct); m++) {
  2192          	if ((XGI21_LCDCapList[m].LVDSHDE == XGIbios_mode[xgifb_mode_idx].xres) &&
                                                                         ^^^^^^^^^^^^^^

  2193                      (XGI21_LCDCapList[m].LVDSVDE == XGIbios_mode[xgifb_mode_idx].yres)) {
                                                                         ^^^^^^^^^^^^^^
  2194                  	xgifb_reg_set(XGI_Pr.P3d4, 0x36, m);
  2195                  }
  2196          }
  2197   }

Smatch complains that we test for this later in the function but we
don't test for it here.

regards,
dan carpenter


More information about the devel mailing list