From: Johan Hovold Date: Wed, 13 Apr 2016 17:18:55 +0000 (+0200) Subject: greybus: manifest: fix illegal free in error path X-Git-Tag: v4.9-rc1~119^2~378^2~21^2~530 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7d963cbe8302d16d2171ecc729782f0d2e7cfbe7;p=karo-tx-linux.git greybus: manifest: fix illegal free in error path The manifest-parsing code could end up leaving the interface vendor_string set to an error pointer that we'd eventually try to free when destroying the interface. Signed-off-by: Johan Hovold Reviewed-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/manifest.c b/drivers/staging/greybus/manifest.c index 070afc619f84..cca4592c15ad 100644 --- a/drivers/staging/greybus/manifest.c +++ b/drivers/staging/greybus/manifest.c @@ -384,15 +384,18 @@ static bool gb_manifest_parse_interface(struct gb_interface *intf, struct manifest_desc *interface_desc) { struct greybus_descriptor_interface *desc_intf = interface_desc->data; + char *str; /* Handle the strings first--they can fail */ - intf->vendor_string = gb_string_get(intf, desc_intf->vendor_stringid); - if (IS_ERR(intf->vendor_string)) + str = gb_string_get(intf, desc_intf->vendor_stringid); + if (IS_ERR(str)) return false; + intf->vendor_string = str; - intf->product_string = gb_string_get(intf, desc_intf->product_stringid); - if (IS_ERR(intf->product_string)) + str = gb_string_get(intf, desc_intf->product_stringid); + if (IS_ERR(str)) goto out_free_vendor_string; + intf->product_string = str; /* Release the interface descriptor, now that we're done with it */ release_manifest_descriptor(interface_desc);