From: Vignesh R Date: Tue, 20 Oct 2015 09:52:00 +0000 (+0530) Subject: dfu: dfu_sf: Pass duplicate devstr to parse_dev X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=30e3ea4c79dd35e97d04546bd39e2468c8ba63ef;p=u-boot.git dfu: dfu_sf: Pass duplicate devstr to parse_dev 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 Reviewed-by: Tom Rini --- diff --git a/drivers/dfu/dfu_sf.c b/drivers/dfu/dfu_sf.c index 7646c6b727..9702eeea20 100644 --- a/drivers/dfu/dfu_sf.c +++ b/drivers/dfu/dfu_sf.c @@ -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;