[PATCH] mtd: nand: don't make vendor-specific code un-set their data pointer
Boris Brezillon
boris.brezillon at free-electrons.com
Tue May 2 00:15:53 PDT 2017
On Mon, 1 May 2017 17:04:51 -0700
Brian Norris <computersforpeace at gmail.com> wrote:
> It makes sense to do this in nand_base.
>
> (Alternatively: we don't really need to do this at all.)
Actually, I was just trying to handle a potential 'double-free' error
nicely (see the 'if (hynix) return;' statement at the beginning of
hynix_nand_cleanup(), but I'm not sure this was a good idea.
Let's drop this assignment.
>
> Signed-off-by: Brian Norris <computersforpeace at gmail.com>
> ---
> Compile tested only
>
> drivers/mtd/nand/nand_base.c | 11 +++++++++--
> drivers/mtd/nand/nand_hynix.c | 1 -
> 2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index ed49a1d634b0..2adcc8cdedf1 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -3910,11 +3910,16 @@ static void nand_manufacturer_detect(struct nand_chip *chip)
> */
> static int nand_manufacturer_init(struct nand_chip *chip)
> {
> + int ret;
> +
> if (!chip->manufacturer.desc || !chip->manufacturer.desc->ops ||
> !chip->manufacturer.desc->ops->init)
> return 0;
>
> - return chip->manufacturer.desc->ops->init(chip);
> + ret = chip->manufacturer.desc->ops->init(chip);
> + if (ret)
> + nand_set_manufacturer_data(chip, NULL);
> + return ret;
> }
>
> /*
> @@ -3927,8 +3932,10 @@ static void nand_manufacturer_cleanup(struct nand_chip *chip)
> {
> /* Release manufacturer private data */
> if (chip->manufacturer.desc && chip->manufacturer.desc->ops &&
> - chip->manufacturer.desc->ops->cleanup)
> + chip->manufacturer.desc->ops->cleanup) {
> chip->manufacturer.desc->ops->cleanup(chip);
> + nand_set_manufacturer_data(chip, NULL);
> + }
> }
>
> /*
> diff --git a/drivers/mtd/nand/nand_hynix.c b/drivers/mtd/nand/nand_hynix.c
> index b12dc7325378..54d99f90aa9f 100644
> --- a/drivers/mtd/nand/nand_hynix.c
> +++ b/drivers/mtd/nand/nand_hynix.c
> @@ -598,7 +598,6 @@ static void hynix_nand_cleanup(struct nand_chip *chip)
>
> kfree(hynix->read_retry);
> kfree(hynix);
> - nand_set_manufacturer_data(chip, NULL);
> }
>
> static int hynix_nand_init(struct nand_chip *chip)
More information about the linux-mtd
mailing list