mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Navid Emamdoost <navid.emamdoost@gmail.com>,
	Thierry Reding <treding@nvidia.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Ben Skeggs <bskeggs@redhat.com>,
	nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Navid Emamdoost <emamd001@umn.edu>, Kangjie Lu <kjlu@umn.edu>,
	Stephen McCamant <smccaman@umn.edu>,
	Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@linux.ie>
Subject: Re: [PATCH] drm/nouveau: Fix memory leak in nouveau_bo_alloc
Date: Tue, 22 Oct 2019 11:40:38 +0200	[thread overview]
Message-ID: <b523c3a1-75a7-d94a-6cc6-58e8a1ad73cd@web.de> (raw)
In-Reply-To: <20191021211449.9104-1-navid.emamdoost@gmail.com>

> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -276,8 +276,10 @@ nouveau_bo_alloc(struct nouveau_cli *cli, u64 *size, int *align, u32 flags,
>  			break;
>  	}
>
> -	if (WARN_ON(pi < 0))
> +	if (WARN_ON(pi < 0)) {
> +		kfree(nvbo);
>  		return ERR_PTR(-EINVAL);
> +	}
>
>  	/* Disable compression if suitable settings couldn't be found. */
>  	if (nvbo->comp && !vmm->page[pi].comp) {

This addition looks correct.
But I would prefer to move such exception handling code to the end of
this function implementation so that duplicate source code will be reduced.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=7d194c2100ad2a6dded545887d02754948ca5241#n450

Regards,
Markus

  reply	other threads:[~2019-10-22  9:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21 21:14 Navid Emamdoost
2019-10-22  9:40 ` Markus Elfring [this message]
2019-11-21 18:09 ` Navid Emamdoost
2019-11-26 17:50   ` Navid Emamdoost
2019-12-11  2:32     ` Navid Emamdoost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b523c3a1-75a7-d94a-6cc6-58e8a1ad73cd@web.de \
    --to=markus.elfring@web.de \
    --cc=airlied@linux.ie \
    --cc=bskeggs@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emamd001@umn.edu \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kjlu@umn.edu \
    --cc=kraxel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=navid.emamdoost@gmail.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=smccaman@umn.edu \
    --cc=treding@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®