From: Colin Ian King <colin.king@canonical.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: VMware Graphics <linux-graphics-maintainer@vmware.com>,
Roland Scheidegger <sroland@vmware.com>,
Zack Rusin <zackr@vmware.com>, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] drm/vmwgfx: Fix memory leak of object fifo on error return
Date: Fri, 14 May 2021 15:32:40 +0100 [thread overview]
Message-ID: <4db89279-4023-d35d-ae53-d29947c53b3e@canonical.com> (raw)
In-Reply-To: <20210514143053.GB1955@kadam>
On 14/05/2021 15:30, Dan Carpenter wrote:
> On Wed, May 12, 2021 at 08:56:09PM +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> In the case where fifo->static_buffer fails to be allocated the
>> error return path neglects to kfree the fifo object. Fix this by
>> adding in the missing kfree.
>>
>> Addresses-Coverity: ("Resource leak")
>> Fixes: 2cd80dbd3551 ("drm/vmwgfx: Add basic support for SVGA3")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>> drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
>> index 027d7d504e78..e5fa210f589e 100644
>> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
>> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c
>> @@ -107,8 +107,10 @@ struct vmw_fifo_state *vmw_fifo_create(struct vmw_private *dev_priv)
>> fifo = kzalloc(sizeof(*fifo), GFP_KERNEL);
>
> This needs an:
>
> if (!fifo)
> return -ENOMEM;
Doh, I completely missed that. I'll send a V2. Thanks Dan.
>
>> fifo->static_buffer_size = VMWGFX_FIFO_STATIC_SIZE;
>> fifo->static_buffer = vmalloc(fifo->static_buffer_size);
>> - if (unlikely(fifo->static_buffer == NULL))
>> + if (unlikely(fifo->static_buffer == NULL)) {
>> + kfree(fifo);
>> return ERR_PTR(-ENOMEM);
>> + }
>
> regards,
> dan carpenter
>
prev parent reply other threads:[~2021-05-14 14:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-12 19:56 Colin King
2021-05-14 14:30 ` Dan Carpenter
2021-05-14 14:32 ` Colin Ian King [this message]
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=4db89279-4023-d35d-ae53-d29947c53b3e@canonical.com \
--to=colin.king@canonical.com \
--cc=airlied@linux.ie \
--cc=dan.carpenter@oracle.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-graphics-maintainer@vmware.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sroland@vmware.com \
--cc=zackr@vmware.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®