[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200421142014.GE2682@kadam>
Date: Tue, 21 Apr 2020 17:20:15 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Shiju Jose <shiju.jose@...wei.com>
Cc: linux-acpi@...r.kernel.org, linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org, rjw@...ysocki.net, bp@...en8.de,
james.morse@....com, helgaas@...nel.org, lenb@...nel.org,
tony.luck@...el.com, gregkh@...uxfoundation.org,
zhangliguang@...ux.alibaba.com, tglx@...utronix.de,
linuxarm@...wei.com, jonathan.cameron@...wei.com,
tanxiaofei@...wei.com, yangyicong@...ilicon.com
Subject: Re: [RESEND PATCH v7 6/6] PCI: hip: Add handling of HiSilicon HIP
PCIe controller errors
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
Powered by blists - more mailing lists