On Tue, Apr 21, 2020 at 02:21:36PM +0100, Shiju Jose wrote: > +static int hisi_pcie_error_handler_probe(struct platform_device *pdev) > +{ > + struct hisi_pcie_error_private *priv; > + int ret; > + > + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + priv->nb.notifier_call = hisi_pcie_notify_error; > + priv->pdev = pdev; > + ret = ghes_register_event_notifier(&priv->nb); > + if (ret) { > + dev_err(&pdev->dev, "%s : ghes_register_event_notifier fail\n", > + __func__); > + return ret; > + } > + > + platform_set_drvdata(pdev, priv); > + > + return 0; > +} > + > +static int hisi_pcie_error_handler_remove(struct platform_device *pdev) > +{ > + struct hisi_pcie_error_private *priv = platform_get_drvdata(pdev); > + > + if (priv) > + ghes_unregister_event_notifier(&priv->nb); Delete this NULL check. The remove function isn't called on stuff which hasn't been allocated. The "never free things which haven't been allocated" rule is a good rule to keep in mind because it makes error handling so much simpler. > + > + kfree(priv); > + > + return 0; > +} regards, dan carpenter