Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a20f3a6d authored by Ishai Rabinovitz's avatar Ishai Rabinovitz Committed by Roland Dreier
Browse files

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: default avatarIshai Rabinovitz <ishai@mellanox.co.il>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 2596627c
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -1621,18 +1621,30 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)
		switch (token) {
		switch (token) {
		case SRP_OPT_ID_EXT:
		case SRP_OPT_ID_EXT:
			p = match_strdup(args);
			p = match_strdup(args);
			if (!p) {
				ret = -ENOMEM;
				goto out;
			}
			target->id_ext = cpu_to_be64(simple_strtoull(p, NULL, 16));
			target->id_ext = cpu_to_be64(simple_strtoull(p, NULL, 16));
			kfree(p);
			kfree(p);
			break;
			break;


		case SRP_OPT_IOC_GUID:
		case SRP_OPT_IOC_GUID:
			p = match_strdup(args);
			p = match_strdup(args);
			if (!p) {
				ret = -ENOMEM;
				goto out;
			}
			target->ioc_guid = cpu_to_be64(simple_strtoull(p, NULL, 16));
			target->ioc_guid = cpu_to_be64(simple_strtoull(p, NULL, 16));
			kfree(p);
			kfree(p);
			break;
			break;


		case SRP_OPT_DGID:
		case SRP_OPT_DGID:
			p = match_strdup(args);
			p = match_strdup(args);
			if (!p) {
				ret = -ENOMEM;
				goto out;
			}
			if (strlen(p) != 32) {
			if (strlen(p) != 32) {
				printk(KERN_WARNING PFX "bad dest GID parameter '%s'\n", p);
				printk(KERN_WARNING PFX "bad dest GID parameter '%s'\n", p);
				kfree(p);
				kfree(p);
@@ -1656,6 +1668,10 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)


		case SRP_OPT_SERVICE_ID:
		case SRP_OPT_SERVICE_ID:
			p = match_strdup(args);
			p = match_strdup(args);
			if (!p) {
				ret = -ENOMEM;
				goto out;
			}
			target->service_id = cpu_to_be64(simple_strtoull(p, NULL, 16));
			target->service_id = cpu_to_be64(simple_strtoull(p, NULL, 16));
			kfree(p);
			kfree(p);
			break;
			break;
@@ -1693,6 +1709,10 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)


		case SRP_OPT_INITIATOR_EXT:
		case SRP_OPT_INITIATOR_EXT:
			p = match_strdup(args);
			p = match_strdup(args);
			if (!p) {
				ret = -ENOMEM;
				goto out;
			}
			target->initiator_ext = cpu_to_be64(simple_strtoull(p, NULL, 16));
			target->initiator_ext = cpu_to_be64(simple_strtoull(p, NULL, 16));
			kfree(p);
			kfree(p);
			break;
			break;