From: Arnd Bergmann <arnd@arndb.de> To: Mauro Carvalho Chehab <mchehab@kernel.org> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>, linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Arnd Bergmann <arnd@arndb.de> Subject: [PATCH 5/9] staging: media: atomisp: fix stack overflow in init_pipe_defaults() Date: Fri, 29 May 2020 22:00:27 +0200 Message-ID: <20200529200031.4117841-5-arnd@arndb.de> (raw) In-Reply-To: <20200529200031.4117841-1-arnd@arndb.de> When building with clang, multiple copies of the structures to be initialized are passed around on the stack and copied locally, using an insane amount of stack space: drivers/staging/media/atomisp/pci/sh_css.c:2371:1: error: stack frame size of 26864 bytes in function 'create_pipe' [-Werror,-Wframe-larger-than=] Use constantly-allocated variables plus an explicit memcpy() to avoid that. Fixes: 6dc9a2568f84 ("media: atomisp: convert default struct values to use compound-literals with designated initializers") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/staging/media/atomisp/pci/sh_css.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c index e91c6029c651..1e8b9d637116 100644 --- a/drivers/staging/media/atomisp/pci/sh_css.c +++ b/drivers/staging/media/atomisp/pci/sh_css.c @@ -2264,6 +2264,12 @@ static enum ia_css_err init_pipe_defaults(enum ia_css_pipe_mode mode, struct ia_css_pipe *pipe, bool copy_pipe) { + static const struct ia_css_pipe default_pipe = IA_CSS_DEFAULT_PIPE; + static const struct ia_css_preview_settings preview = IA_CSS_DEFAULT_PREVIEW_SETTINGS; + static const struct ia_css_capture_settings capture = IA_CSS_DEFAULT_CAPTURE_SETTINGS; + static const struct ia_css_video_settings video = IA_CSS_DEFAULT_VIDEO_SETTINGS; + static const struct ia_css_yuvpp_settings yuvpp = IA_CSS_DEFAULT_YUVPP_SETTINGS; + if (!pipe) { IA_CSS_ERROR("NULL pipe parameter"); @@ -2271,14 +2277,14 @@ init_pipe_defaults(enum ia_css_pipe_mode mode, } /* Initialize pipe to pre-defined defaults */ - *pipe = IA_CSS_DEFAULT_PIPE; + memcpy(pipe, &default_pipe, sizeof(default_pipe)); /* TODO: JB should not be needed, but temporary backward reference */ switch (mode) { case IA_CSS_PIPE_MODE_PREVIEW: pipe->mode = IA_CSS_PIPE_ID_PREVIEW; - pipe->pipe_settings.preview = IA_CSS_DEFAULT_PREVIEW_SETTINGS; + memcpy(&pipe->pipe_settings.preview, &preview, sizeof(preview)); break; case IA_CSS_PIPE_MODE_CAPTURE: if (copy_pipe) { @@ -2286,11 +2292,11 @@ init_pipe_defaults(enum ia_css_pipe_mode mode, } else { pipe->mode = IA_CSS_PIPE_ID_CAPTURE; } - pipe->pipe_settings.capture = IA_CSS_DEFAULT_CAPTURE_SETTINGS; + memcpy(&pipe->pipe_settings.capture, &capture, sizeof(capture)); break; case IA_CSS_PIPE_MODE_VIDEO: pipe->mode = IA_CSS_PIPE_ID_VIDEO; - pipe->pipe_settings.video = IA_CSS_DEFAULT_VIDEO_SETTINGS; + memcpy(&pipe->pipe_settings.video, &video, sizeof(video)); break; case IA_CSS_PIPE_MODE_ACC: pipe->mode = IA_CSS_PIPE_ID_ACC; @@ -2300,7 +2306,7 @@ init_pipe_defaults(enum ia_css_pipe_mode mode, break; case IA_CSS_PIPE_MODE_YUVPP: pipe->mode = IA_CSS_PIPE_ID_YUVPP; - pipe->pipe_settings.yuvpp = IA_CSS_DEFAULT_YUVPP_SETTINGS; + memcpy(&pipe->pipe_settings.yuvpp, &yuvpp, sizeof(yuvpp)); break; default: return IA_CSS_ERR_INVALID_ARGUMENTS; -- 2.26.2
next prev parent reply other threads:[~2020-05-29 20:03 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-29 20:00 [PATCH 1/9] staging: media: atomisp: fix incorrect NULL pointer check Arnd Bergmann 2020-05-29 20:00 ` [PATCH 2/9] staging: media: atomisp: declare 'struct device' before using it Arnd Bergmann 2020-05-30 2:55 ` Nathan Chancellor 2020-05-29 20:00 ` [PATCH 3/9] staging: media: atomisp: annotate an unused function Arnd Bergmann 2020-05-30 2:56 ` Nathan Chancellor 2020-05-29 20:00 ` [PATCH 4/9] staging: media: atomisp: fix a type conversion warning Arnd Bergmann 2020-05-29 20:00 ` Arnd Bergmann [this message] 2020-05-30 2:57 ` [PATCH 5/9] staging: media: atomisp: fix stack overflow in init_pipe_defaults() Nathan Chancellor 2020-05-29 20:00 ` [PATCH 6/9] staging: media: atomisp: fix type mismatch Arnd Bergmann 2020-05-29 20:00 ` [PATCH 7/9] staging: media: atomisp: fix enum type mixups Arnd Bergmann 2020-05-30 3:00 ` Nathan Chancellor 2020-05-29 20:00 ` [PATCH 8/9] staging: media: atomisp: disable all custom formats Arnd Bergmann 2020-05-30 3:03 ` Nathan Chancellor 2020-05-29 20:00 ` [PATCH 9/9] staging: media: atomisp: add PMIC_OPREGION dependency Arnd Bergmann 2020-05-30 3:11 ` Nathan Chancellor 2020-05-30 5:25 ` Mauro Carvalho Chehab 2020-05-29 20:04 ` [PATCH 1/9] staging: media: atomisp: fix incorrect NULL pointer check Nick Desaulniers 2020-05-29 20:23 ` Arnd Bergmann 2020-05-29 20:31 ` Arnd Bergmann 2020-05-30 2:49 ` Nathan Chancellor 2020-05-30 9:22 ` Mauro Carvalho Chehab
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200529200031.4117841-5-arnd@arndb.de \ --to=arnd@arndb.de \ --cc=clang-built-linux@googlegroups.com \ --cc=devel@driverdev.osuosl.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ --cc=mchehab@kernel.org \ --cc=sakari.ailus@linux.intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Unnamed repository; edit this file 'description' to name the repository. This inbox may be cloned and mirrored by anyone: git clone --mirror http://archive.lwn.net:8080/linux-media/0 linux-media/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-media linux-media/ http://archive.lwn.net:8080/linux-media \ linux-media@vger.kernel.org lwn-linux-media@archive.lwn.net public-inbox-index linux-media Example config snippet for mirrors. Newsgroup available over NNTP: nntp://archive.lwn.net/lwn.kernel.linux-media AGPL code for this site: git clone https://public-inbox.org/public-inbox.git