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