Skip to content

Commit b937186

Browse files
Md Sadre Alammiquelraynal
authored andcommitted
mtd: rawnand: qcom: Fix build issue on x86 architecture
Fix a buffer overflow issue in qcom_clear_bam_transaction by using struct_group to group related fields and avoid FORTIFY_SOURCE warnings. On x86 architecture, the following error occurs due to warnings being treated as errors: In function ‘fortify_memset_chk’, inlined from ‘qcom_clear_bam_transaction’ at drivers/mtd/nand/qpic_common.c:88:2: ./include/linux/fortify-string.h:480:25: error: call to ‘__write_overflow_field’ declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning] 480 | __write_overflow_field(p_size_field, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ LD [M] drivers/mtd/nand/nandcore.o CC [M] drivers/w1/masters/mxc_w1.o cc1: all warnings being treated as errors This patch addresses the issue by grouping the related fields in struct bam_transaction using struct_group and updating the memset call accordingly. Fixes: 8c52932 ("mtd: rawnand: qcom: cleanup qcom_nandc driver") Signed-off-by: Md Sadre Alam <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent 8d3cd6b commit b937186

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

drivers/mtd/nand/qpic_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void qcom_clear_bam_transaction(struct qcom_nand_controller *nandc)
8585
if (!nandc->props->supports_bam)
8686
return;
8787

88-
memset(&bam_txn->bam_ce_pos, 0, sizeof(u32) * 8);
88+
memset(&bam_txn->bam_positions, 0, sizeof(bam_txn->bam_positions));
8989
bam_txn->last_data_desc = NULL;
9090

9191
sg_init_table(bam_txn->cmd_sgl, nandc->max_cwperpage *

include/linux/mtd/nand-qpic-common.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,17 @@ struct bam_transaction {
254254
struct dma_async_tx_descriptor *last_data_desc;
255255
struct dma_async_tx_descriptor *last_cmd_desc;
256256
struct completion txn_done;
257-
u32 bam_ce_pos;
258-
u32 bam_ce_start;
259-
u32 cmd_sgl_pos;
260-
u32 cmd_sgl_start;
261-
u32 tx_sgl_pos;
262-
u32 tx_sgl_start;
263-
u32 rx_sgl_pos;
264-
u32 rx_sgl_start;
257+
struct_group(bam_positions,
258+
u32 bam_ce_pos;
259+
u32 bam_ce_start;
260+
u32 cmd_sgl_pos;
261+
u32 cmd_sgl_start;
262+
u32 tx_sgl_pos;
263+
u32 tx_sgl_start;
264+
u32 rx_sgl_pos;
265+
u32 rx_sgl_start;
266+
267+
);
265268
};
266269

267270
/*

0 commit comments

Comments
 (0)