]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - security-integration-tree/security-ti-u-boot.git/commitdiff
dfu: dfu_sf: Pass duplicate devstr to parse_dev
authorVignesh R <vigneshr@ti.com>
Wed, 28 Oct 2015 04:53:29 +0000 (10:23 +0530)
committerLokesh Vutla <lokeshvutla@ti.com>
Thu, 29 Oct 2015 06:03:36 +0000 (11:33 +0530)
parse_dev() alters the string pointed by devstr parameter. Due to this
subsequent parsing of sf entities will fail, as string pointed by devstr
is no longer valid sf dev arguments.
Fix this by passing pointer to the copy of the string to parse_dev
instead of pointer to the actual devstr.

Signed-off-by: Vignesh R <vigneshr@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
drivers/dfu/dfu_sf.c

index 7646c6b7270c1859a6cf10985f65670a3f818bdb..9702eeea202a97f87b9c24b152e335d792b4f49b 100644 (file)
@@ -115,8 +115,10 @@ static struct spi_flash *parse_dev(char *devstr)
 int dfu_fill_entity_sf(struct dfu_entity *dfu, char *devstr, char *s)
 {
        char *st;
+       char *devstr_bkup = strdup(devstr);
 
-       dfu->data.sf.dev = parse_dev(devstr);
+       dfu->data.sf.dev = parse_dev(devstr_bkup);
+       free(devstr_bkup);
        if (!dfu->data.sf.dev)
                return -ENODEV;