Commit 89f3b319 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Mauro Carvalho Chehab
Browse files

media: staging: media: atomisp: fix stack overflow in init_pipe_defaults()



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.

Co-authored-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>

Fixes: 6dc9a256 ("media: atomisp: convert default struct values to use compound-literals with designated initializers")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 5b552b19
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -122,8 +122,7 @@ struct ia_css_frame_info {
	struct ia_css_crop_info crop_info;
};

#define IA_CSS_BINARY_DEFAULT_FRAME_INFO \
(struct ia_css_frame_info) { \
#define IA_CSS_BINARY_DEFAULT_FRAME_INFO { \
	.format			= IA_CSS_FRAME_FORMAT_NUM,  \
	.raw_bayer_order	= IA_CSS_BAYER_ORDER_NUM, \
}
@@ -185,8 +184,7 @@ struct ia_css_frame {
		       info.format */
};

#define DEFAULT_FRAME \
(struct ia_css_frame) { \
#define DEFAULT_FRAME { \
	.info			= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
	.dynamic_queue_id	= SH_CSS_INVALID_QUEUE_ID, \
	.buf_type		= IA_CSS_BUFFER_TYPE_INVALID, \
+5 −10
Original line number Diff line number Diff line
@@ -40,8 +40,7 @@ struct ia_css_preview_settings {
	struct ia_css_pipe *acc_pipe;
};

#define IA_CSS_DEFAULT_PREVIEW_SETTINGS \
(struct ia_css_preview_settings) { \
#define IA_CSS_DEFAULT_PREVIEW_SETTINGS { \
	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.preview_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.vf_pp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
@@ -65,8 +64,7 @@ struct ia_css_capture_settings {
	unsigned int num_yuv_scaler;
};

#define IA_CSS_DEFAULT_CAPTURE_SETTINGS \
(struct ia_css_capture_settings) { \
#define IA_CSS_DEFAULT_CAPTURE_SETTINGS { \
	.copy_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.primary_binary		= {IA_CSS_BINARY_DEFAULT_SETTINGS}, \
	.pre_isp_binary		= IA_CSS_BINARY_DEFAULT_SETTINGS, \
@@ -91,8 +89,7 @@ struct ia_css_video_settings {
	unsigned int num_yuv_scaler;
};

#define IA_CSS_DEFAULT_VIDEO_SETTINGS \
(struct ia_css_video_settings) { \
#define IA_CSS_DEFAULT_VIDEO_SETTINGS { \
	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.video_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
	.vf_pp_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
@@ -108,8 +105,7 @@ struct ia_css_yuvpp_settings {
	unsigned int num_output;
};

#define IA_CSS_DEFAULT_YUVPP_SETTINGS \
(struct ia_css_yuvpp_settings) { \
#define IA_CSS_DEFAULT_YUVPP_SETTINGS { \
	.copy_binary	= IA_CSS_BINARY_DEFAULT_SETTINGS, \
}

@@ -157,8 +153,7 @@ struct ia_css_pipe {
	unsigned int pipe_num;
};

#define IA_CSS_DEFAULT_PIPE \
(struct ia_css_pipe) { \
#define IA_CSS_DEFAULT_PIPE { \
	.config			= DEFAULT_PIPE_CONFIG, \
	.info			= DEFAULT_PIPE_INFO, \
	.mode			= IA_CSS_PIPE_ID_ACC, /* (pipe_id) */ \
+2 −4
Original line number Diff line number Diff line
@@ -149,8 +149,7 @@ struct ia_css_pipe_config {
/**
 * Default settings for newly created pipe configurations.
 */
#define DEFAULT_PIPE_CONFIG \
(struct ia_css_pipe_config) { \
#define DEFAULT_PIPE_CONFIG { \
	.mode			= IA_CSS_PIPE_MODE_PREVIEW, \
	.isp_pipe_version	= 1, \
	.output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
@@ -203,8 +202,7 @@ struct ia_css_pipe_info {
/**
 * Defaults for ia_css_pipe_info structs.
 */
#define DEFAULT_PIPE_INFO \
(struct ia_css_pipe_info) { \
#define DEFAULT_PIPE_INFO {\
	.output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	.vf_output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
	.raw_output_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
+2 −4
Original line number Diff line number Diff line
@@ -392,8 +392,7 @@ struct ia_css_grid_info {
};

/* defaults for ia_css_grid_info structs */
#define DEFAULT_GRID_INFO \
(struct ia_css_grid_info) { \
#define DEFAULT_GRID_INFO { \
	.dvs_grid	= DEFAULT_DVS_GRID_INFO, \
	.vamem_type	= IA_CSS_VAMEM_TYPE_1 \
}
@@ -485,8 +484,7 @@ struct ia_css_capture_config {
};

/* default settings for ia_css_capture_config structs */
#define DEFAULT_CAPTURE_CONFIG \
(struct ia_css_capture_config) { \
#define DEFAULT_CAPTURE_CONFIG { \
	.mode	= IA_CSS_CAPTURE_MODE_PRIMARY, \
}

+4 −5
Original line number Diff line number Diff line
@@ -197,11 +197,10 @@ struct ia_css_dvs_stat_grid_info {

/* DVS statistics generated by accelerator default grid info
 */
#define DEFAULT_DVS_GRID_INFO \
(union ia_css_dvs_grid_u) { \
	.dvs_stat_grid_info = (struct ia_css_dvs_stat_grid_info) { \
#define DEFAULT_DVS_GRID_INFO { \
	.dvs_stat_grid_info = { \
		.fe_roi_cfg = { \
			[1] = (struct dvs_stat_public_dvs_level_fe_roi_cfg) { \
			[1] = { \
			    .x_start = 4 \
			} \
		} \
Loading