target: Fix alua_access_state attribute OOPs for un-configured devices [Linux 3.15]

This Linux kernel change "target: Fix alua_access_state attribute OOPs for un-configured devices" is included in the Linux 3.15 release. This change is authored by Nicholas Bellinger <nab [at]> on Fri Jun 6 00:52:57 2014 -0700. The commit for this change in Linux stable tree is f145377 (patch).

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:


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 <[email protected]>
Reported-by: Philip Gaw <[email protected]>
Cc: Chris Boot <[email protected]>
Cc: Philip Gaw <[email protected]>
Cc: [email protected] # 3.8+
Signed-off-by: Nicholas Bellinger <[email protected]>

There are 5 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/target/target_core_configfs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 60a9ae6..bf55c5a 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2227,6 +2227,11 @@ static ssize_t target_core_alua_tg_pt_gp_store_attr_alua_access_state(
            " tg_pt_gp ID: %hun", tg_pt_gp->tg_pt_gp_valid_id);
        return -EINVAL;
+   if (!(dev->dev_flags & DF_CONFIGURED)) {
+       pr_err("Unable to set alua_access_state while device is"
+              " not configuredn");
+       return -ENODEV;
+   }

    ret = kstrtoul(page, 0, &tmp);
    if (ret < 0) {

Leave a Reply

Your email address will not be published. Required fields are marked *