RDMA/qib: Validate ->show()/store() callbacks before calling them
[linux-2.6-microblaze.git] / drivers / infiniband / hw / qib / qib_sysfs.c
index 3926be7..568b21e 100644 (file)
@@ -301,6 +301,9 @@ static ssize_t qib_portattr_show(struct kobject *kobj,
        struct qib_pportdata *ppd =
                container_of(kobj, struct qib_pportdata, pport_kobj);
 
+       if (!pattr->show)
+               return -EIO;
+
        return pattr->show(ppd, buf);
 }
 
@@ -312,6 +315,9 @@ static ssize_t qib_portattr_store(struct kobject *kobj,
        struct qib_pportdata *ppd =
                container_of(kobj, struct qib_pportdata, pport_kobj);
 
+       if (!pattr->store)
+               return -EIO;
+
        return pattr->store(ppd, buf, len);
 }