diff options
author | Jon Mason <jon.mason@intel.com> | 2013-01-22 13:35:40 -0500 |
---|---|---|
committer | Jon Mason <jon.mason@intel.com> | 2013-05-15 13:57:17 -0400 |
commit | 186f27ff9f9ec5c110739ced88ce9f8fca053882 (patch) | |
tree | 4f4738bb432a30ae4a0d3e2ddf13251cf3095746 /drivers/ntb | |
parent | f722406faae2d073cc1d01063d1123c35425939e (diff) |
NTB: variable dereferenced before check
Correct instances of variable dereferencing before checking its value on
the functions exported to the client drivers. Also, add sanity checks
for all exported functions.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jon Mason <jon.mason@intel.com>
Diffstat (limited to 'drivers/ntb')
-rw-r--r-- | drivers/ntb/ntb_transport.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c index e0bdfd7f9930..74c58125acfc 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c | |||
@@ -1210,12 +1210,14 @@ EXPORT_SYMBOL_GPL(ntb_transport_create_queue); | |||
1210 | */ | 1210 | */ |
1211 | void ntb_transport_free_queue(struct ntb_transport_qp *qp) | 1211 | void ntb_transport_free_queue(struct ntb_transport_qp *qp) |
1212 | { | 1212 | { |
1213 | struct pci_dev *pdev = ntb_query_pdev(qp->ndev); | 1213 | struct pci_dev *pdev; |
1214 | struct ntb_queue_entry *entry; | 1214 | struct ntb_queue_entry *entry; |
1215 | 1215 | ||
1216 | if (!qp) | 1216 | if (!qp) |
1217 | return; | 1217 | return; |
1218 | 1218 | ||
1219 | pdev = ntb_query_pdev(qp->ndev); | ||
1220 | |||
1219 | cancel_delayed_work_sync(&qp->link_work); | 1221 | cancel_delayed_work_sync(&qp->link_work); |
1220 | 1222 | ||
1221 | ntb_unregister_db_callback(qp->ndev, qp->qp_num); | 1223 | ntb_unregister_db_callback(qp->ndev, qp->qp_num); |
@@ -1371,12 +1373,13 @@ EXPORT_SYMBOL_GPL(ntb_transport_link_up); | |||
1371 | */ | 1373 | */ |
1372 | void ntb_transport_link_down(struct ntb_transport_qp *qp) | 1374 | void ntb_transport_link_down(struct ntb_transport_qp *qp) |
1373 | { | 1375 | { |
1374 | struct pci_dev *pdev = ntb_query_pdev(qp->ndev); | 1376 | struct pci_dev *pdev; |
1375 | int rc, val; | 1377 | int rc, val; |
1376 | 1378 | ||
1377 | if (!qp) | 1379 | if (!qp) |
1378 | return; | 1380 | return; |
1379 | 1381 | ||
1382 | pdev = ntb_query_pdev(qp->ndev); | ||
1380 | qp->client_ready = NTB_LINK_DOWN; | 1383 | qp->client_ready = NTB_LINK_DOWN; |
1381 | 1384 | ||
1382 | rc = ntb_read_local_spad(qp->ndev, QP_LINKS, &val); | 1385 | rc = ntb_read_local_spad(qp->ndev, QP_LINKS, &val); |
@@ -1408,6 +1411,9 @@ EXPORT_SYMBOL_GPL(ntb_transport_link_down); | |||
1408 | */ | 1411 | */ |
1409 | bool ntb_transport_link_query(struct ntb_transport_qp *qp) | 1412 | bool ntb_transport_link_query(struct ntb_transport_qp *qp) |
1410 | { | 1413 | { |
1414 | if (!qp) | ||
1415 | return false; | ||
1416 | |||
1411 | return qp->qp_link == NTB_LINK_UP; | 1417 | return qp->qp_link == NTB_LINK_UP; |
1412 | } | 1418 | } |
1413 | EXPORT_SYMBOL_GPL(ntb_transport_link_query); | 1419 | EXPORT_SYMBOL_GPL(ntb_transport_link_query); |
@@ -1422,6 +1428,9 @@ EXPORT_SYMBOL_GPL(ntb_transport_link_query); | |||
1422 | */ | 1428 | */ |
1423 | unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp) | 1429 | unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp) |
1424 | { | 1430 | { |
1431 | if (!qp) | ||
1432 | return 0; | ||
1433 | |||
1425 | return qp->qp_num; | 1434 | return qp->qp_num; |
1426 | } | 1435 | } |
1427 | EXPORT_SYMBOL_GPL(ntb_transport_qp_num); | 1436 | EXPORT_SYMBOL_GPL(ntb_transport_qp_num); |
@@ -1436,6 +1445,9 @@ EXPORT_SYMBOL_GPL(ntb_transport_qp_num); | |||
1436 | */ | 1445 | */ |
1437 | unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp) | 1446 | unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp) |
1438 | { | 1447 | { |
1448 | if (!qp) | ||
1449 | return 0; | ||
1450 | |||
1439 | return qp->tx_max_frame - sizeof(struct ntb_payload_header); | 1451 | return qp->tx_max_frame - sizeof(struct ntb_payload_header); |
1440 | } | 1452 | } |
1441 | EXPORT_SYMBOL_GPL(ntb_transport_max_size); | 1453 | EXPORT_SYMBOL_GPL(ntb_transport_max_size); |