Hello Yueyao Zhu, The patch c034a43e72dd: "staging: typec: Fairchild FUSB302 Type-c chip driver" from Apr 27, 2017, leads to the following static checker warning: drivers/staging/typec/fusb302/fusb302.c:180 _fusb302_log() error: testing array offset 'chip->logbuffer_head' after use. drivers/staging/typec/fusb302/fusb302.c 156 static void _fusb302_log(struct fusb302_chip *chip, const char *fmt, 157 va_list args) 158 { 159 char tmpbuffer[LOG_BUFFER_ENTRY_SIZE]; 160 u64 ts_nsec = local_clock(); 161 unsigned long rem_nsec; 162 163 if (!chip->logbuffer[chip->logbuffer_head]) { 164 chip->logbuffer[chip->logbuffer_head] = ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Writing to array offset. 165 kzalloc(LOG_BUFFER_ENTRY_SIZE, GFP_KERNEL); 166 if (!chip->logbuffer[chip->logbuffer_head]) 167 return; 168 } 169 170 vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args); 171 172 mutex_lock(&chip->logbuffer_lock); 173 174 if (fusb302_log_full(chip)) { 175 chip->logbuffer_head = max(chip->logbuffer_head - 1, 0); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ We decrement chip->logbuffer_head unless it's already 0. 176 strlcpy(tmpbuffer, "overflow", sizeof(tmpbuffer)); 177 } 178 179 if (chip->logbuffer_head < 0 || 180 chip->logbuffer_head >= LOG_BUFFER_ENTRIES) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This test is too late. But it looks like we can just delete it since it can never be true. 181 dev_warn(chip->dev, 182 "Bad log buffer index %d\n", chip->logbuffer_head); 183 goto abort; 184 } 185 regards, dan carpenter _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel