summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2026-09-28 13:07:29 -0700
committerMiquel Raynal <miquel.raynal@bootlin.com>2026-10-12 20:18:23 +0200
commit104f277e8a469f71ac3c74a0e9ebb8bf64c3fa06 (patch)
tree4e414fe08c13e0dc08180f35a5c74ad6222e2720 /drivers
parent94623942a66e031826756f9c92dbde9a12e2b4d2 (diff)
downloadlinux-next-104f277e8a469f71ac3c74a0e9ebb8bf64c3fa06.tar.gz
linux-next-104f277e8a469f71ac3c74a0e9ebb8bf64c3fa06.zip
mtd: rawnand: fsl_ifc: allocate shared ctrl with devm_kzalloc
Allocate the shared fsl_ifc_nand_ctrl structure against the controller device, which outlives all NAND child devices, so it is freed automatically. This drops the manual kfree() and the broken chip counter that was decremented in remove() but never incremented anywhere, leaking the structure and leaving the freed pointer in ctrl->nand on re-probe. Assisted-by: LLM Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/nand/raw/fsl_ifc_nand.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/drivers/mtd/nand/raw/fsl_ifc_nand.c b/drivers/mtd/nand/raw/fsl_ifc_nand.c
index be6bbc1c184d..cc75b6a67e07 100644
--- a/drivers/mtd/nand/raw/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/raw/fsl_ifc_nand.c
@@ -49,7 +49,6 @@ struct fsl_ifc_nand_ctrl {
unsigned int index; /* Pointer to next byte to 'read' */
unsigned int oob; /* Non zero if operating on OOB data */
unsigned int eccread; /* Non zero for a full-page ECC read */
- unsigned int counter; /* counter for the initializations */
unsigned int max_bitflips; /* Saved during READ0 cmd */
};
@@ -1023,15 +1022,13 @@ static int fsl_ifc_nand_probe(struct platform_device *dev)
mutex_lock(&fsl_ifc_nand_mutex);
if (!fsl_ifc_ctrl_dev->nand) {
- ifc_nand_ctrl = kzalloc_obj(*ifc_nand_ctrl);
+ ifc_nand_ctrl = devm_kzalloc(fsl_ifc_ctrl_dev->dev, sizeof(*ifc_nand_ctrl),
+ GFP_KERNEL);
if (!ifc_nand_ctrl) {
mutex_unlock(&fsl_ifc_nand_mutex);
return -ENOMEM;
}
- ifc_nand_ctrl->read_bytes = 0;
- ifc_nand_ctrl->index = 0;
- ifc_nand_ctrl->addr = NULL;
fsl_ifc_ctrl_dev->nand = ifc_nand_ctrl;
nand_controller_init(&ifc_nand_ctrl->controller);
@@ -1105,14 +1102,6 @@ static void fsl_ifc_nand_remove(struct platform_device *dev)
nand_cleanup(chip);
fsl_ifc_chip_remove(priv);
-
- mutex_lock(&fsl_ifc_nand_mutex);
- ifc_nand_ctrl->counter--;
- if (!ifc_nand_ctrl->counter) {
- fsl_ifc_ctrl_dev->nand = NULL;
- kfree(ifc_nand_ctrl);
- }
- mutex_unlock(&fsl_ifc_nand_mutex);
}
static const struct of_device_id fsl_ifc_nand_match[] = {