target: Fix alua_access_state attribute OOPs for un-configured devices

This patch fixes a OOPs where an attempt to write to the per-device
alua_access_state configfs attribute at:

/sys/kernel/config/target/core/$HBA/$DEV/alua/$TG_PT_GP/alua_access_state

results in an NULL pointer dereference when the backend device has not
yet been configured.

This patch adds an explicit check for DF_CONFIGURED, and fails with
-ENODEV to avoid this case.

Reported-by: Chris Boot <crb@tiger-computing.co.uk>
Reported-by: Philip Gaw <pgaw@darktech.org.uk>
Cc: Chris Boot <crb@tiger-computing.co.uk>
Cc: Philip Gaw <pgaw@darktech.org.uk>
Cc: stable@vger.kernel.org # 3.8+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

Changed files
+5
drivers
+5
drivers/target/target_core_configfs.c
··· 2227 2227 " tg_pt_gp ID: %hu\n", tg_pt_gp->tg_pt_gp_valid_id); 2228 2228 return -EINVAL; 2229 2229 } 2230 + if (!(dev->dev_flags & DF_CONFIGURED)) { 2231 + pr_err("Unable to set alua_access_state while device is" 2232 + " not configured\n"); 2233 + return -ENODEV; 2234 + } 2230 2235 2231 2236 ret = kstrtoul(page, 0, &tmp); 2232 2237 if (ret < 0) {