pnp: be consistent about testing pnp_dev->protocol in pnp_bus_{suspend,resume} pnp_can_{disable,write}() dereference pnp_dev->protocol. So do the pnp_{stop,start}_dev() the tests protect, but let's be consistent at least. Spotted by Adrian Bunk and the Coverity checker. Signed-off-by: Rene Herman diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index 12a1645..170af61 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c @@ -160,15 +160,15 @@ static int pnp_bus_suspend(struct device *dev, pm_message_t state) if (error) return error; } - - if (pnp_can_disable(pnp_dev)) { - error = pnp_stop_dev(pnp_dev); - if (error) - return error; + if (pnp_dev->protocol) { + if (pnp_can_disable(pnp_dev)) { + error = pnp_stop_dev(pnp_dev); + if (error) + return error; + } + if (pnp_dev->protocol->suspend) + pnp_dev->protocol->suspend(pnp_dev, state); } - - if (pnp_dev->protocol && pnp_dev->protocol->suspend) - pnp_dev->protocol->suspend(pnp_dev, state); return 0; } @@ -181,21 +181,21 @@ static int pnp_bus_resume(struct device *dev) if (!pnp_drv) return 0; - if (pnp_dev->protocol && pnp_dev->protocol->resume) - pnp_dev->protocol->resume(pnp_dev); + if (pnp_dev->protocol) { + if (pnp_dev->protocol->resume) + pnp_dev->protocol->resume(pnp_dev); - if (pnp_can_write(pnp_dev)) { - error = pnp_start_dev(pnp_dev); - if (error) - return error; + if (pnp_can_write(pnp_dev)) { + error = pnp_start_dev(pnp_dev); + if (error) + return error; + } } - if (pnp_drv->resume) { error = pnp_drv->resume(pnp_dev); if (error) return error; } - return 0; }