IB/srp: Check match_strdup() return

Checks if the kmalloc in match_strdup() was successful, and bail out
on looking at the token if it failed.

Signed-off-by: Ishai Rabinovitz <ishai@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by Ishai Rabinovitz and committed by Roland Dreier a20f3a6d 2596627c

+20
+20
drivers/infiniband/ulp/srp/ib_srp.c
··· 1621 1621 switch (token) { 1622 1622 case SRP_OPT_ID_EXT: 1623 1623 p = match_strdup(args); 1624 + if (!p) { 1625 + ret = -ENOMEM; 1626 + goto out; 1627 + } 1624 1628 target->id_ext = cpu_to_be64(simple_strtoull(p, NULL, 16)); 1625 1629 kfree(p); 1626 1630 break; 1627 1631 1628 1632 case SRP_OPT_IOC_GUID: 1629 1633 p = match_strdup(args); 1634 + if (!p) { 1635 + ret = -ENOMEM; 1636 + goto out; 1637 + } 1630 1638 target->ioc_guid = cpu_to_be64(simple_strtoull(p, NULL, 16)); 1631 1639 kfree(p); 1632 1640 break; 1633 1641 1634 1642 case SRP_OPT_DGID: 1635 1643 p = match_strdup(args); 1644 + if (!p) { 1645 + ret = -ENOMEM; 1646 + goto out; 1647 + } 1636 1648 if (strlen(p) != 32) { 1637 1649 printk(KERN_WARNING PFX "bad dest GID parameter '%s'\n", p); 1638 1650 kfree(p); ··· 1668 1656 1669 1657 case SRP_OPT_SERVICE_ID: 1670 1658 p = match_strdup(args); 1659 + if (!p) { 1660 + ret = -ENOMEM; 1661 + goto out; 1662 + } 1671 1663 target->service_id = cpu_to_be64(simple_strtoull(p, NULL, 16)); 1672 1664 kfree(p); 1673 1665 break; ··· 1709 1693 1710 1694 case SRP_OPT_INITIATOR_EXT: 1711 1695 p = match_strdup(args); 1696 + if (!p) { 1697 + ret = -ENOMEM; 1698 + goto out; 1699 + } 1712 1700 target->initiator_ext = cpu_to_be64(simple_strtoull(p, NULL, 16)); 1713 1701 kfree(p); 1714 1702 break;