All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Manivannan Sadhasivam <mani@kernel.org>,
	Md Sadre Alam <quic_mdalam@quicinc.com>,
	Sricharan Ramabadhran <quic_srichara@quicinc.com>
Cc: Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	Pratyush Yadav <pratyush@kernel.org>,
	Michael Walle <michael@walle.cc>, <linux-mtd@lists.infradead.org>,
	<linux-arm-kernel@lists.infradead.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: [PATCH 7/8] mtd: rawnand: qcom: Early structure initialization
Date: Sun, 16 Jul 2023 16:46:11 +0200	[thread overview]
Message-ID: <20230716144612.32132-8-miquel.raynal@bootlin.com> (raw)
In-Reply-To: <20230716144612.32132-1-miquel.raynal@bootlin.com>

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>
---
 drivers/mtd/nand/raw/qcom_nandc.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index cb6ccaa19224..4fc8dafa8f03 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -2600,8 +2600,6 @@ static void qcom_parse_instructions(struct nand_chip *chip,
 	unsigned int op_id;
 	int i;
 
-	memset(q_op, 0, sizeof(*q_op));
-
 	for (op_id = 0; op_id < subop->ninstrs; op_id++) {
 		unsigned int offset, naddrs;
 		const u8 *addrs;
@@ -2681,7 +2679,7 @@ static int qcom_read_status_exec(struct nand_chip *chip,
 	struct qcom_nand_host *host = to_qcom_nand_host(chip);
 	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
 	struct nand_ecc_ctrl *ecc = &chip->ecc;
-	struct qcom_op q_op;
+	struct qcom_op q_op = {};
 	const struct nand_op_instr *instr = NULL;
 	unsigned int op_id = 0;
 	unsigned int len = 0;
@@ -2744,7 +2742,7 @@ static int qcom_read_id_type_exec(struct nand_chip *chip, const struct nand_subo
 {
 	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
 	struct qcom_nand_host *host = to_qcom_nand_host(chip);
-	struct qcom_op q_op;
+	struct qcom_op q_op = {};
 	const struct nand_op_instr *instr = NULL;
 	unsigned int op_id = 0;
 	unsigned int len = 0;
@@ -2795,7 +2793,7 @@ static int qcom_misc_cmd_type_exec(struct nand_chip *chip, const struct nand_sub
 {
 	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
 	struct qcom_nand_host *host = to_qcom_nand_host(chip);
-	struct qcom_op q_op;
+	struct qcom_op q_op = {};
 	int ret = 0;
 
 	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_
 {
 	struct qcom_nand_host *host = to_qcom_nand_host(chip);
 	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
-	struct qcom_op q_op;
+	struct qcom_op q_op = {};
 	const struct nand_op_instr *instr = NULL;
 	unsigned int op_id = 0;
 	unsigned int len = 0;
@@ -2935,7 +2933,7 @@ static int qcom_erase_cmd_type_exec(struct nand_chip *chip, const struct nand_su
 {
 	struct qcom_nand_host *host = to_qcom_nand_host(chip);
 	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
-	struct qcom_op q_op;
+	struct qcom_op q_op = {};
 	int ret = 0;
 
 	qcom_parse_instructions(chip, subop, &q_op);
-- 
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Manivannan Sadhasivam <mani@kernel.org>,
	Md Sadre Alam <quic_mdalam@quicinc.com>,
	Sricharan Ramabadhran <quic_srichara@quicinc.com>
Cc: Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	Pratyush Yadav <pratyush@kernel.org>,
	Michael Walle <michael@walle.cc>,
	linux-mtd@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: [PATCH 7/8] mtd: rawnand: qcom: Early structure initialization
Date: Sun, 16 Jul 2023 16:46:11 +0200	[thread overview]
Message-ID: <20230716144612.32132-8-miquel.raynal@bootlin.com> (raw)
In-Reply-To: <20230716144612.32132-1-miquel.raynal@bootlin.com>

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>
---
 drivers/mtd/nand/raw/qcom_nandc.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index cb6ccaa19224..4fc8dafa8f03 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -2600,8 +2600,6 @@ static void qcom_parse_instructions(struct nand_chip *chip,
 	unsigned int op_id;
 	int i;
 
-	memset(q_op, 0, sizeof(*q_op));
-
 	for (op_id = 0; op_id < subop->ninstrs; op_id++) {
 		unsigned int offset, naddrs;
 		const u8 *addrs;
@@ -2681,7 +2679,7 @@ static int qcom_read_status_exec(struct nand_chip *chip,
 	struct qcom_nand_host *host = to_qcom_nand_host(chip);
 	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
 	struct nand_ecc_ctrl *ecc = &chip->ecc;
-	struct qcom_op q_op;
+	struct qcom_op q_op = {};
 	const struct nand_op_instr *instr = NULL;
 	unsigned int op_id = 0;
 	unsigned int len = 0;
@@ -2744,7 +2742,7 @@ static int qcom_read_id_type_exec(struct nand_chip *chip, const struct nand_subo
 {
 	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
 	struct qcom_nand_host *host = to_qcom_nand_host(chip);
-	struct qcom_op q_op;
+	struct qcom_op q_op = {};
 	const struct nand_op_instr *instr = NULL;
 	unsigned int op_id = 0;
 	unsigned int len = 0;
@@ -2795,7 +2793,7 @@ static int qcom_misc_cmd_type_exec(struct nand_chip *chip, const struct nand_sub
 {
 	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
 	struct qcom_nand_host *host = to_qcom_nand_host(chip);
-	struct qcom_op q_op;
+	struct qcom_op q_op = {};
 	int ret = 0;
 
 	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_
 {
 	struct qcom_nand_host *host = to_qcom_nand_host(chip);
 	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
-	struct qcom_op q_op;
+	struct qcom_op q_op = {};
 	const struct nand_op_instr *instr = NULL;
 	unsigned int op_id = 0;
 	unsigned int len = 0;
@@ -2935,7 +2933,7 @@ static int qcom_erase_cmd_type_exec(struct nand_chip *chip, const struct nand_su
 {
 	struct qcom_nand_host *host = to_qcom_nand_host(chip);
 	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
-	struct qcom_op q_op;
+	struct qcom_op q_op = {};
 	int ret = 0;
 
 	qcom_parse_instructions(chip, subop, &q_op);
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-07-16 14:47 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-16 14:46 [PATCH 0/8] mtd: rawnand: qcom: Misc fixes Miquel Raynal
2023-07-16 14:46 ` Miquel Raynal
2023-07-16 14:46 ` [PATCH 1/8] mtd: rawnand: qcom: Use the BIT() macro Miquel Raynal
2023-07-16 14:46   ` Miquel Raynal
2023-07-17  2:25   ` Manivannan Sadhasivam
2023-07-17  2:25     ` Manivannan Sadhasivam
2023-07-28  2:16   ` Tudor Ambarus
2023-07-28  2:16     ` Tudor Ambarus
2023-07-28 12:35   ` Miquel Raynal
2023-07-28 12:35     ` Miquel Raynal
2023-07-16 14:46 ` [PATCH 2/8] mtd: rawnand: qcom: Use u8 instead of uint8_t Miquel Raynal
2023-07-16 14:46   ` Miquel Raynal
2023-07-17  2:26   ` Manivannan Sadhasivam
2023-07-17  2:26     ` Manivannan Sadhasivam
2023-07-28  2:17   ` Tudor Ambarus
2023-07-28  2:17     ` Tudor Ambarus
2023-07-28 12:35   ` Miquel Raynal
2023-07-28 12:35     ` Miquel Raynal
2023-07-16 14:46 ` [PATCH 3/8] mtd: rawnand: qcom: Fix alignment with open parenthesis Miquel Raynal
2023-07-16 14:46   ` Miquel Raynal
2023-07-17  2:27   ` Manivannan Sadhasivam
2023-07-17  2:27     ` Manivannan Sadhasivam
2023-07-28  2:17   ` Tudor Ambarus
2023-07-28  2:17     ` Tudor Ambarus
2023-07-16 14:46 ` [PATCH 4/8] mtd: rawnand: qcom: Fix the spacing Miquel Raynal
2023-07-16 14:46   ` Miquel Raynal
2023-07-17  2:28   ` Manivannan Sadhasivam
2023-07-17  2:28     ` Manivannan Sadhasivam
2023-07-28  2:18   ` Tudor Ambarus
2023-07-28  2:18     ` Tudor Ambarus
2023-07-28 12:34   ` Miquel Raynal
2023-07-28 12:34     ` Miquel Raynal
2023-07-16 14:46 ` [PATCH 5/8] mtd: rawnand: qcom: Fix wrong indentation Miquel Raynal
2023-07-16 14:46   ` Miquel Raynal
2023-07-17  2:29   ` Manivannan Sadhasivam
2023-07-17  2:29     ` Manivannan Sadhasivam
2023-07-28  2:20   ` Tudor Ambarus
2023-07-28  2:20     ` Tudor Ambarus
2023-07-28 12:34   ` Miquel Raynal
2023-07-28 12:34     ` Miquel Raynal
2023-07-16 14:46 ` [PATCH 6/8] mtd: rawnand: qcom: Fix a typo Miquel Raynal
2023-07-16 14:46   ` Miquel Raynal
2023-07-17  2:30   ` Manivannan Sadhasivam
2023-07-17  2:30     ` Manivannan Sadhasivam
2023-07-28  2:22   ` Tudor Ambarus
2023-07-28  2:22     ` Tudor Ambarus
2023-07-28 12:34   ` Miquel Raynal
2023-07-28 12:34     ` Miquel Raynal
2023-07-16 14:46 ` Miquel Raynal [this message]
2023-07-16 14:46   ` [PATCH 7/8] mtd: rawnand: qcom: Early structure initialization Miquel Raynal
2023-07-17  2:31   ` Manivannan Sadhasivam
2023-07-17  2:31     ` Manivannan Sadhasivam
2023-07-27 15:03   ` Tudor Ambarus
2023-07-27 15:03     ` Tudor Ambarus
2023-07-27 15:14     ` Miquel Raynal
2023-07-27 15:14       ` Miquel Raynal
2023-07-28  2:23   ` Tudor Ambarus
2023-07-28  2:23     ` Tudor Ambarus
2023-07-28 12:34   ` Miquel Raynal
2023-07-28 12:34     ` Miquel Raynal
2023-07-16 14:46 ` [PATCH 8/8] mtd: rawnand: qcom: Fix address parsing within ->exec_op() Miquel Raynal
2023-07-16 14:46   ` Miquel Raynal
2023-07-17  6:38   ` Manivannan Sadhasivam
2023-07-17  6:38     ` Manivannan Sadhasivam
2023-07-27 14:59     ` Miquel Raynal
2023-07-27 14:59       ` Miquel Raynal
2023-07-28  2:31       ` Tudor Ambarus
2023-07-28  2:31         ` Tudor Ambarus
2023-07-28  7:56         ` Miquel Raynal
2023-07-28  7:56           ` Miquel Raynal
2023-07-28  2:33       ` Sricharan Ramabadhran
2023-07-28  2:33         ` Sricharan Ramabadhran
2023-07-28  4:14         ` Sricharan Ramabadhran
2023-07-28  4:14           ` Sricharan Ramabadhran
2023-07-28  7:55           ` Miquel Raynal
2023-07-28  7:55             ` Miquel Raynal
2023-07-28  2:27   ` Tudor Ambarus
2023-07-28  2:27     ` Tudor Ambarus
2023-07-28 12:34   ` Miquel Raynal
2023-07-28 12:34     ` Miquel Raynal

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=20230716144612.32132-8-miquel.raynal@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mani@kernel.org \
    --cc=michael@walle.cc \
    --cc=pratyush@kernel.org \
    --cc=quic_mdalam@quicinc.com \
    --cc=quic_srichara@quicinc.com \
    --cc=richard@nod.at \
    --cc=tudor.ambarus@linaro.org \
    --cc=vigneshr@ti.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.