Skip to content

Commit 13dc49d

Browse files
julianwiedmanngregkh
authored andcommitted
s390/qeth: lock the card while changing its hsuid
[ Upstream commit 5b6c7b5 ] qeth_l3_dev_hsuid_store() initially checks the card state, but doesn't take the conf_mutex to ensure that the card stays in this state while being reconfigured. Rework the code to take this lock, and drop a redundant state check in a helper function. Fixes: b333293 ("qeth: add support for af_iucv HiperSockets transport") Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent be5fa7e commit 13dc49d

2 files changed

Lines changed: 28 additions & 17 deletions

File tree

drivers/s390/net/qeth_core_main.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,11 +3378,6 @@ int qeth_configure_cq(struct qeth_card *card, enum qeth_cq cq)
33783378
goto out;
33793379
}
33803380

3381-
if (card->state != CARD_STATE_DOWN) {
3382-
rc = -1;
3383-
goto out;
3384-
}
3385-
33863381
qeth_free_qdio_queues(card);
33873382
card->options.cq = cq;
33883383
rc = 0;

drivers/s390/net/qeth_l3_sys.c

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,24 +270,36 @@ static ssize_t qeth_l3_dev_hsuid_store(struct device *dev,
270270
struct device_attribute *attr, const char *buf, size_t count)
271271
{
272272
struct qeth_card *card = dev_get_drvdata(dev);
273+
int rc = 0;
273274
char *tmp;
274-
int rc;
275275

276276
if (!card)
277277
return -EINVAL;
278278

279279
if (!IS_IQD(card))
280280
return -EPERM;
281-
if (card->state != CARD_STATE_DOWN)
282-
return -EPERM;
283-
if (card->options.sniffer)
284-
return -EPERM;
285-
if (card->options.cq == QETH_CQ_NOTAVAILABLE)
286-
return -EPERM;
281+
282+
mutex_lock(&card->conf_mutex);
283+
if (card->state != CARD_STATE_DOWN) {
284+
rc = -EPERM;
285+
goto out;
286+
}
287+
288+
if (card->options.sniffer) {
289+
rc = -EPERM;
290+
goto out;
291+
}
292+
293+
if (card->options.cq == QETH_CQ_NOTAVAILABLE) {
294+
rc = -EPERM;
295+
goto out;
296+
}
287297

288298
tmp = strsep((char **)&buf, "\n");
289-
if (strlen(tmp) > 8)
290-
return -EINVAL;
299+
if (strlen(tmp) > 8) {
300+
rc = -EINVAL;
301+
goto out;
302+
}
291303

292304
if (card->options.hsuid[0])
293305
/* delete old ip address */
@@ -298,11 +310,13 @@ static ssize_t qeth_l3_dev_hsuid_store(struct device *dev,
298310
card->options.hsuid[0] = '\0';
299311
memcpy(card->dev->perm_addr, card->options.hsuid, 9);
300312
qeth_configure_cq(card, QETH_CQ_DISABLED);
301-
return count;
313+
goto out;
302314
}
303315

304-
if (qeth_configure_cq(card, QETH_CQ_ENABLED))
305-
return -EPERM;
316+
if (qeth_configure_cq(card, QETH_CQ_ENABLED)) {
317+
rc = -EPERM;
318+
goto out;
319+
}
306320

307321
snprintf(card->options.hsuid, sizeof(card->options.hsuid),
308322
"%-8s", tmp);
@@ -311,6 +325,8 @@ static ssize_t qeth_l3_dev_hsuid_store(struct device *dev,
311325

312326
rc = qeth_l3_modify_hsuid(card, true);
313327

328+
out:
329+
mutex_unlock(&card->conf_mutex);
314330
return rc ? rc : count;
315331
}
316332

0 commit comments

Comments
 (0)