For cases where @firmware is declared "const char *", use function kstrdup_const() to avoid needlessly creating another copy on the heap.
Unified · Split
| @@ -1996,7 +1996,7 @@ static void rproc_type_release(struct device *dev) · 1995 unmodified lines | |||
| 1996 | if (rproc->index >= 0) | 1996 | if (rproc->index >= 0) |
| 1997 | ida_simple_remove(&rproc_dev_index, rproc->index); | 1997 | ida_simple_remove(&rproc_dev_index, rproc->index); |
| 1998 | 1998 | ||
| 1999 | kfree(rproc->firmware); | 1999 | kfree_const(rproc->firmware); |
| 2000 | kfree(rproc->ops); | 2000 | kfree(rproc->ops); |
| 2001 | kfree(rproc); | 2001 | kfree(rproc); |
| 2002 | } | 2002 | } |
| @@ -2009,7 +2009,7 @@ static const struct device_type rproc_type = { · 6 unmodified lines | |||
| 2009 | static int rproc_alloc_firmware(struct rproc *rproc, | 2009 | static int rproc_alloc_firmware(struct rproc *rproc, |
| 2010 | const char *name, const char *firmware) | 2010 | const char *name, const char *firmware) |
| 2011 | { | 2011 | { |
| 2012 | char *p; | 2012 | const char *p; |
| 2013 | 2013 | ||
| 2014 | if (!firmware) | 2014 | if (!firmware) |
| 2015 | /* | 2015 | /* |
| @@ -2018,7 +2018,7 @@ static int rproc_alloc_firmware(struct rproc *rproc, · 2 unmodified lines | |||
| 2018 | */ | 2018 | */ |
| 2019 | p = kasprintf(GFP_KERNEL, "rproc-%s-fw", name); | 2019 | p = kasprintf(GFP_KERNEL, "rproc-%s-fw", name); |
| 2020 | else | 2020 | else |
| 2021 | p = kstrdup(firmware, GFP_KERNEL); | 2021 | p = kstrdup_const(firmware, GFP_KERNEL); |
| 2022 | 2022 | ||
| 2023 | if (!p) | 2023 | if (!p) |
| 2024 | return -ENOMEM; | 2024 | return -ENOMEM; |
| @@ -2122,7 +2122,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, · 97 unmodified lines | |||
| 2122 | return rproc; | 2122 | return rproc; |
| 2123 | 2123 | ||
| 2124 | free_firmware: | 2124 | free_firmware: |
| 2125 | kfree(rproc->firmware); | 2125 | kfree_const(rproc->firmware); |
| 2126 | free_rproc: | 2126 | free_rproc: |
| 2127 | kfree(rproc); | 2127 | kfree(rproc); |
| 2128 | return NULL; | 2128 | return NULL; |
| @@ -489,7 +489,7 @@ struct rproc { · 488 unmodified lines | |||
| 489 | struct list_head node; | 489 | struct list_head node; |
| 490 | struct iommu_domain *domain; | 490 | struct iommu_domain *domain; |
| 491 | const char *name; | 491 | const char *name; |
| 492 | char *firmware; | 492 | const char *firmware; |
| 493 | void *priv; | 493 | void *priv; |
| 494 | struct rproc_ops *ops; | 494 | struct rproc_ops *ops; |
| 495 | struct device dev; | 495 | struct device dev; |