mirror of https://gitee.com/openkylin/linux.git
mtd: bcm47xxsflash: convert kzalloc to avoid invalid access
mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash not its member. So I use devm_kazlloc instead of kazlloc to avoid it. * Changelog: convert to devm_kzalloc Signed-off-by: Libo chen <libo.chen@huawei.com> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> [Brian: fixed conflicts] Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
parent
ebc6e4b652
commit
d2b1bd1422
|
@ -117,11 +117,9 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
|
||||||
struct bcm47xxsflash *b47s;
|
struct bcm47xxsflash *b47s;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
b47s = kzalloc(sizeof(*b47s), GFP_KERNEL);
|
b47s = devm_kzalloc(&pdev->dev, sizeof(*b47s), GFP_KERNEL);
|
||||||
if (!b47s) {
|
if (!b47s)
|
||||||
err = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
sflash->priv = b47s;
|
sflash->priv = b47s;
|
||||||
|
|
||||||
b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash);
|
b47s->bcma_cc = container_of(sflash, struct bcma_drv_cc, sflash);
|
||||||
|
@ -146,18 +144,13 @@ static int bcm47xxsflash_bcma_probe(struct platform_device *pdev)
|
||||||
err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
|
err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
|
||||||
if (err) {
|
if (err) {
|
||||||
pr_err("Failed to register MTD device: %d\n", err);
|
pr_err("Failed to register MTD device: %d\n", err);
|
||||||
goto err_dev_reg;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bcm47xxsflash_poll(b47s, HZ / 10))
|
if (bcm47xxsflash_poll(b47s, HZ / 10))
|
||||||
pr_warn("Serial flash busy\n");
|
pr_warn("Serial flash busy\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_dev_reg:
|
|
||||||
kfree(&b47s->mtd);
|
|
||||||
out:
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
|
static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
|
||||||
|
@ -166,7 +159,6 @@ static int bcm47xxsflash_bcma_remove(struct platform_device *pdev)
|
||||||
struct bcm47xxsflash *b47s = sflash->priv;
|
struct bcm47xxsflash *b47s = sflash->priv;
|
||||||
|
|
||||||
mtd_device_unregister(&b47s->mtd);
|
mtd_device_unregister(&b47s->mtd);
|
||||||
kfree(b47s);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue