soc: fsl: dpio: avoid stack usage warning
Subsystems (2)
PATCH 1/1 soc: fsl: dpio: avoid stack usage warning
A 1024 byte variable on the stack will warn on any 32-bit architecture during compile-testing, and is generally a bad idea anyway:
fsl/dpio/dpio-service.c: In function 'dpaa2_io_service_enqueue_multiple_desc_fq':fsl/dpio/dpio-service.c:495:1: error: the frame size of 1032 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
There are currently no callers of this function, so I cannot tell whether dynamic memory allocation is allowed once callers are added. Change it to kcalloc for now, if anyone gets a warning about calling this in atomic context after they start using it, they can fix it later.
--- drivers/soc/fsl/dpio/dpio-service.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/soc/fsl/dpio/dpio-service.c +13 -5
@@ -478,12 +478,17 @@ int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d, const struct dpaa2_fd *fd, int nb) { - int i; -struct qbman_eq_desc ed[32 ]; +struct qbman_eq_desc *ed =kcalloc (sizeof (struct qbman_eq_desc ),32 ,GFP_KERNEL ); +int i, ret; + +if (!ed) +return -ENOMEM ; d =service_select (d); -if (!d) -return -ENODEV ; +if (!d) { + ret = -ENODEV ; + goto out; + }for (i =0 ; i < nb; i++) {qbman_eq_desc_clear (&ed[i]);
@@ -491,7 +496,10 @@ int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d,qbman_eq_desc_set_fq (&ed[i], fqid[i]); } -return qbman_swp_enqueue_multiple_desc (d->swp, &ed[0 ], fd, nb); + ret =qbman_swp_enqueue_multiple_desc (d->swp, &ed[0 ], fd, nb); +out: +kfree (ed); +return ret; }EXPORT_SYMBOL (dpaa2_io_service_enqueue_multiple_desc_fq);
Signature · 7 lines
2.26.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 22 lines · Arnd Bergmann
A 1024 byte variable on the stack will warn on any 32-bit architecture during compile-testing, and is generally a bad idea anyway:
fsl/dpio/dpio-service.c: In function 'dpaa2_io_service_enqueue_multiple_desc_fq':fsl/dpio/dpio-service.c:495:1: error: the frame size of 1032 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]There are currently no callers of this function, so I cannot tell whether dynamic memory allocation is allowed once callers are added. Change it to kcalloc for now, if anyone gets a warning about calling this in atomic context after they start using it, they can fix it later.
Fixes 9d98809711ae ("soc: fsl: dpio: Adding QMAN multiple enqueue interface")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/soc/fsl/dpio/dpio-service.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)drivers/soc/fsl/dpio/dpio-service.c +0
-0
drivers/soc/fsl/dpio/dpio-service.c int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d, · line 481
Quoted 6 lines
drivers/soc/fsl/dpio/dpio-service.c +1
-2@@ -478,12 +478,17 @@ int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d, const struct dpaa2_fd *fd, int nb) { - int i; -struct qbman_eq_desc ed[32 ]; +struct qbman_eq_desc *ed =kcalloc (sizeof (struct qbman_eq_desc ),32 ,GFP_KERNEL );
I think you need to rearrange this to be more compliant with the coding style.
Quoted 31 lines
drivers/soc/fsl/dpio/dpio-service.c +12
-3+int i, ret; + +if (!ed) +return -ENOMEM ; d =service_select (d); -if (!d) -return -ENODEV ; +if (!d) { + ret = -ENODEV ; + goto out; + }for (i =0 ; i < nb; i++) {qbman_eq_desc_clear (&ed[i]);@@ -491,7 +496,10 @@ int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d,qbman_eq_desc_set_fq (&ed[i], fqid[i]); } -return qbman_swp_enqueue_multiple_desc (d->swp, &ed[0 ], fd, nb); + ret =qbman_swp_enqueue_multiple_desc (d->swp, &ed[0 ], fd, nb); +out: +kfree (ed); +return ret; }EXPORT_SYMBOL (dpaa2_io_service_enqueue_multiple_desc_fq);Signature · 1 line
2.26.0
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up
Quoted 7 lines · Russell King - ARM Linux admin
drivers/soc/fsl/dpio/dpio-service.c int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d, · line 481
Quoted 3 lines · Arnd Bergmann
drivers/soc/fsl/dpio/dpio-service.c +1
-2-int i; -struct qbman_eq_desc ed[32 ]; +struct qbman_eq_desc *ed =kcalloc (sizeof (struct qbman_eq_desc ),32 ,GFP_KERNEL );I think you need to rearrange this to be more compliant with the coding style.
Ok, I've updated this now to move the allocation into a new line and applied this and the other fsl patch into the arm/fixes branch for v5.7.
Arnd