Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] PCI: cpqphp_ctrl.c: board_replaced(): remove dead code

The Coverity checker correctly noted, that in function board_replaced in
drivers/pci/hotplug/cpqphp_ctrl.c, the variable src always has the
value 8, and therefore much code after the

...
if (rc || src) {
...
if (rc)
return rc;
else
return 1;
}
...

can never be called.

This patch removes the unreachable code in this function fixing kernel
Bugzilla #6073.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Adrian Bunk and committed by
Greg Kroah-Hartman
1305e918 0cccd0c2

+14 -62
+14 -62
drivers/pci/hotplug/cpqphp_ctrl.c
··· 1282 1282 u8 hp_slot; 1283 1283 u8 temp_byte; 1284 1284 u8 adapter_speed; 1285 - u32 index; 1286 1285 u32 rc = 0; 1287 - u32 src = 8; 1288 1286 1289 1287 hp_slot = func->device - ctrl->slot_device_offset; 1290 1288 ··· 1366 1368 1367 1369 rc = cpqhp_configure_board(ctrl, func); 1368 1370 1369 - if (rc || src) { 1370 - /* If configuration fails, turn it off 1371 - * Get slot won't work for devices behind 1372 - * bridges, but in this case it will always be 1373 - * called for the "base" bus/dev/func of an 1374 - * adapter. */ 1375 - 1376 - mutex_lock(&ctrl->crit_sect); 1377 - 1378 - amber_LED_on (ctrl, hp_slot); 1379 - green_LED_off (ctrl, hp_slot); 1380 - slot_disable (ctrl, hp_slot); 1381 - 1382 - set_SOGO(ctrl); 1383 - 1384 - /* Wait for SOBS to be unset */ 1385 - wait_for_ctrl_irq (ctrl); 1386 - 1387 - mutex_unlock(&ctrl->crit_sect); 1388 - 1389 - if (rc) 1390 - return rc; 1391 - else 1392 - return 1; 1393 - } 1394 - 1395 - func->status = 0; 1396 - func->switch_save = 0x10; 1397 - 1398 - index = 1; 1399 - while (((func = cpqhp_slot_find(func->bus, func->device, index)) != NULL) && !rc) { 1400 - rc |= cpqhp_configure_board(ctrl, func); 1401 - index++; 1402 - } 1403 - 1404 - if (rc) { 1405 - /* If configuration fails, turn it off 1406 - * Get slot won't work for devices behind 1407 - * bridges, but in this case it will always be 1408 - * called for the "base" bus/dev/func of an 1409 - * adapter. */ 1410 - 1411 - mutex_lock(&ctrl->crit_sect); 1412 - 1413 - amber_LED_on (ctrl, hp_slot); 1414 - green_LED_off (ctrl, hp_slot); 1415 - slot_disable (ctrl, hp_slot); 1416 - 1417 - set_SOGO(ctrl); 1418 - 1419 - /* Wait for SOBS to be unset */ 1420 - wait_for_ctrl_irq (ctrl); 1421 - 1422 - mutex_unlock(&ctrl->crit_sect); 1423 - 1424 - return rc; 1425 - } 1426 - /* Done configuring so turn LED on full time */ 1371 + /* If configuration fails, turn it off 1372 + * Get slot won't work for devices behind 1373 + * bridges, but in this case it will always be 1374 + * called for the "base" bus/dev/func of an 1375 + * adapter. */ 1427 1376 1428 1377 mutex_lock(&ctrl->crit_sect); 1429 1378 1430 - green_LED_on (ctrl, hp_slot); 1379 + amber_LED_on (ctrl, hp_slot); 1380 + green_LED_off (ctrl, hp_slot); 1381 + slot_disable (ctrl, hp_slot); 1431 1382 1432 1383 set_SOGO(ctrl); 1433 1384 ··· 1384 1437 wait_for_ctrl_irq (ctrl); 1385 1438 1386 1439 mutex_unlock(&ctrl->crit_sect); 1387 - rc = 0; 1440 + 1441 + if (rc) 1442 + return rc; 1443 + else 1444 + return 1; 1445 + 1388 1446 } else { 1389 1447 /* Something is wrong 1390 1448