Skip to content

Commit e260efe

Browse files
committed
mtd: rawnand: qcom: Early structure initialization
Instead of allocating a structure on the stack with random data and then expect the callee to perform the initialization (which is, in general, error prone), prefer zeroing the structure explicitly at allocation and provide the already zeroed area, so no explicit memset operation is needed. It is probably safer to do so, so we limit the timeframe when dirty data could actually be accessed by mistake. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Manivannan Sadhasivam <mani@kernel.org> Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org> Link: https://lore.kernel.org/linux-mtd/20230716144612.32132-8-miquel.raynal@bootlin.com
1 parent 548b750 commit e260efe

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

drivers/mtd/nand/raw/qcom_nandc.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,8 +2600,6 @@ static void qcom_parse_instructions(struct nand_chip *chip,
26002600
unsigned int op_id;
26012601
int i;
26022602

2603-
memset(q_op, 0, sizeof(*q_op));
2604-
26052603
for (op_id = 0; op_id < subop->ninstrs; op_id++) {
26062604
unsigned int offset, naddrs;
26072605
const u8 *addrs;
@@ -2681,7 +2679,7 @@ static int qcom_read_status_exec(struct nand_chip *chip,
26812679
struct qcom_nand_host *host = to_qcom_nand_host(chip);
26822680
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
26832681
struct nand_ecc_ctrl *ecc = &chip->ecc;
2684-
struct qcom_op q_op;
2682+
struct qcom_op q_op = {};
26852683
const struct nand_op_instr *instr = NULL;
26862684
unsigned int op_id = 0;
26872685
unsigned int len = 0;
@@ -2744,7 +2742,7 @@ static int qcom_read_id_type_exec(struct nand_chip *chip, const struct nand_subo
27442742
{
27452743
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
27462744
struct qcom_nand_host *host = to_qcom_nand_host(chip);
2747-
struct qcom_op q_op;
2745+
struct qcom_op q_op = {};
27482746
const struct nand_op_instr *instr = NULL;
27492747
unsigned int op_id = 0;
27502748
unsigned int len = 0;
@@ -2795,7 +2793,7 @@ static int qcom_misc_cmd_type_exec(struct nand_chip *chip, const struct nand_sub
27952793
{
27962794
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
27972795
struct qcom_nand_host *host = to_qcom_nand_host(chip);
2798-
struct qcom_op q_op;
2796+
struct qcom_op q_op = {};
27992797
int ret = 0;
28002798

28012799
qcom_parse_instructions(chip, subop, &q_op);
@@ -2838,7 +2836,7 @@ static int qcom_param_page_type_exec(struct nand_chip *chip, const struct nand_
28382836
{
28392837
struct qcom_nand_host *host = to_qcom_nand_host(chip);
28402838
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
2841-
struct qcom_op q_op;
2839+
struct qcom_op q_op = {};
28422840
const struct nand_op_instr *instr = NULL;
28432841
unsigned int op_id = 0;
28442842
unsigned int len = 0;
@@ -2935,7 +2933,7 @@ static int qcom_erase_cmd_type_exec(struct nand_chip *chip, const struct nand_su
29352933
{
29362934
struct qcom_nand_host *host = to_qcom_nand_host(chip);
29372935
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
2938-
struct qcom_op q_op;
2936+
struct qcom_op q_op = {};
29392937
int ret = 0;
29402938

29412939
qcom_parse_instructions(chip, subop, &q_op);

0 commit comments

Comments
 (0)