[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2095a4a2-7db5-4de6-9609-d8e6a5adf27f@suse.com>
Date: Wed, 29 May 2024 15:28:44 +0200
From: Jürgen Groß <jgross@...e.com>
To: yskelg@...il.com, Stefano Stabellini <sstabellini@...nel.org>,
Oleksandr Tyshchenko <oleksandr_tyshchenko@...m.com>
Cc: skhan@...uxfoundation.org, sj@...nel.org,
Austin Kim <austindh.kim@...il.com>, shjy180909@...il.com,
linux-kernel@...r.kernel.org, xen-devel@...ts.xenproject.org,
linux-kernel-mentees@...ts.linuxfoundation.org
Subject: Re: [PATCH] xen/xenbus: handle pointer to NULL in alloc/free_pdev
On 29.05.24 15:19, yskelg@...il.com wrote:
> From: Yunseong Kim <yskelg@...il.com>
>
> Modify 'alloc_pdev()' to set 'pdev->xdev' to NULL
> if 'xen_pcibk_init_devices()' fails. This ensures that 'pdev->xdev' does
> not point to 'xdev' when 'pdev' is freed.
> And modify 'free_pdev()' to set 'pdev' to NULL.
>
> Signed-off-by: Yunseong Kim <yskelg@...il.com>
> ---
> drivers/xen/xen-pciback/xenbus.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciback/xenbus.c
> index b11e401f1b1e..f1709b8e284a 100644
> --- a/drivers/xen/xen-pciback/xenbus.c
> +++ b/drivers/xen/xen-pciback/xenbus.c
> @@ -54,6 +54,7 @@ static struct xen_pcibk_device *alloc_pdev(struct xenbus_device *xdev)
> INIT_WORK(&pdev->op_work, xen_pcibk_do_op);
>
> if (xen_pcibk_init_devices(pdev)) {
> + pdev->xdev = NULL;
> kfree(pdev);
> pdev = NULL;
> }
> @@ -102,6 +103,7 @@ static void free_pdev(struct xen_pcibk_device *pdev)
> pdev->xdev = NULL;
>
> kfree(pdev);
> + pdev = NULL;
> }
>
> static int xen_pcibk_do_attach(struct xen_pcibk_device *pdev, int gnt_ref,
NAK!
Please stop that nonsense. NULL-ing pointers which have no chance to be used any
more is just adding code for no purpose at all.
Please don't send other iterations of this patch. You are wasting review
bandwidth.
Juergen
Powered by blists - more mailing lists