aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/ipath/ipath_mad.c16
-rw-r--r--drivers/infiniband/hw/ipath/ipath_sysfs.c9
2 files changed, 17 insertions, 8 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_mad.c b/drivers/infiniband/hw/ipath/ipath_mad.c
index 72d1db89db8f..25908b02fbe5 100644
--- a/drivers/infiniband/hw/ipath/ipath_mad.c
+++ b/drivers/infiniband/hw/ipath/ipath_mad.c
@@ -87,7 +87,8 @@ static int recv_subn_get_nodeinfo(struct ib_smp *smp,
87 struct ipath_devdata *dd = to_idev(ibdev)->dd; 87 struct ipath_devdata *dd = to_idev(ibdev)->dd;
88 u32 vendor, majrev, minrev; 88 u32 vendor, majrev, minrev;
89 89
90 if (smp->attr_mod) 90 /* GUID 0 is illegal */
91 if (smp->attr_mod || (dd->ipath_guid == 0))
91 smp->status |= IB_SMP_INVALID_FIELD; 92 smp->status |= IB_SMP_INVALID_FIELD;
92 93
93 nip->base_version = 1; 94 nip->base_version = 1;
@@ -131,10 +132,15 @@ static int recv_subn_get_guidinfo(struct ib_smp *smp,
131 * We only support one GUID for now. If this changes, the 132 * We only support one GUID for now. If this changes, the
132 * portinfo.guid_cap field needs to be updated too. 133 * portinfo.guid_cap field needs to be updated too.
133 */ 134 */
134 if (startgx == 0) 135 if (startgx == 0) {
135 /* The first is a copy of the read-only HW GUID. */ 136 __be64 g = to_idev(ibdev)->dd->ipath_guid;
136 *p = to_idev(ibdev)->dd->ipath_guid; 137 if (g == 0)
137 else 138 /* GUID 0 is illegal */
139 smp->status |= IB_SMP_INVALID_FIELD;
140 else
141 /* The first is a copy of the read-only HW GUID. */
142 *p = g;
143 } else
138 smp->status |= IB_SMP_INVALID_FIELD; 144 smp->status |= IB_SMP_INVALID_FIELD;
139 145
140 return reply(smp); 146 return reply(smp);
diff --git a/drivers/infiniband/hw/ipath/ipath_sysfs.c b/drivers/infiniband/hw/ipath/ipath_sysfs.c
index b48ebf62e5dd..182de34f9f47 100644
--- a/drivers/infiniband/hw/ipath/ipath_sysfs.c
+++ b/drivers/infiniband/hw/ipath/ipath_sysfs.c
@@ -257,7 +257,7 @@ static ssize_t store_guid(struct device *dev,
257 struct ipath_devdata *dd = dev_get_drvdata(dev); 257 struct ipath_devdata *dd = dev_get_drvdata(dev);
258 ssize_t ret; 258 ssize_t ret;
259 unsigned short guid[8]; 259 unsigned short guid[8];
260 __be64 nguid; 260 __be64 new_guid;
261 u8 *ng; 261 u8 *ng;
262 int i; 262 int i;
263 263
@@ -266,7 +266,7 @@ static ssize_t store_guid(struct device *dev,
266 &guid[4], &guid[5], &guid[6], &guid[7]) != 8) 266 &guid[4], &guid[5], &guid[6], &guid[7]) != 8)
267 goto invalid; 267 goto invalid;
268 268
269 ng = (u8 *) &nguid; 269 ng = (u8 *) &new_guid;
270 270
271 for (i = 0; i < 8; i++) { 271 for (i = 0; i < 8; i++) {
272 if (guid[i] > 0xff) 272 if (guid[i] > 0xff)
@@ -274,7 +274,10 @@ static ssize_t store_guid(struct device *dev,
274 ng[i] = guid[i]; 274 ng[i] = guid[i];
275 } 275 }
276 276
277 dd->ipath_guid = nguid; 277 if (new_guid == 0)
278 goto invalid;
279
280 dd->ipath_guid = new_guid;
278 dd->ipath_nguid = 1; 281 dd->ipath_nguid = 1;
279 282
280 ret = strlen(buf); 283 ret = strlen(buf);