All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@infradead.org>,
	Pawel Osciak <pawel@osciak.com>,
	Kyungmin Park <kyungmin.park@samsung.com>
Subject: Re: [PATCH] [media] videobuf2: avoid memory leak on errors
Date: Mon, 21 Dec 2015 07:54:37 +0100	[thread overview]
Message-ID: <5677A22D.4010908@samsung.com> (raw)
In-Reply-To: <b62ef37c6e2f30d1b5ce3889212050d738c04885.1450455268.git.mchehab@osg.samsung.com>

Hello,

On 2015-12-18 17:14, Mauro Carvalho Chehab wrote:
> As reported by smatch:
> 	drivers/media/v4l2-core/videobuf2-core.c:2415 __vb2_init_fileio() warn: possible memory leak of 'fileio'
>
> While here, avoid the usage of sizeof(struct foo_struct).
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>   drivers/media/v4l2-core/videobuf2-core.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index e6890d47cdcb..c5d49d7a0d76 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -2406,13 +2406,15 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read)
>   		(read) ? "read" : "write", count, q->fileio_read_once,
>   		q->fileio_write_immediately);
>   
> -	fileio = kzalloc(sizeof(struct vb2_fileio_data), GFP_KERNEL);
> +	fileio = kzalloc(sizeof(*fileio), GFP_KERNEL);
>   	if (fileio == NULL)
>   		return -ENOMEM;
>   
>   	fileio->b = kzalloc(q->buf_struct_size, GFP_KERNEL);
> -	if (fileio->b == NULL)
> +	if (fileio->b == NULL) {
> +		kfree(fileio);
>   		return -ENOMEM;
> +	}
>   
>   	fileio->read_once = q->fileio_read_once;
>   	fileio->write_immediately = q->fileio_write_immediately;

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


      reply	other threads:[~2015-12-21  6:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-18 16:14 [PATCH] [media] videobuf2: avoid memory leak on errors Mauro Carvalho Chehab
2015-12-21  6:54 ` Marek Szyprowski [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=5677A22D.4010908@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=mchehab@osg.samsung.com \
    --cc=pawel@osciak.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.