From: Carsten Emde <C.Emde@osadl.org>
To: Alexey Khoroshilov <khoroshilov@ispras.ru>
Cc: David Airlie <airlied@linux.ie>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
ldv-project@ispras.ru
Subject: Re: [PATCH] drm/edid: Fix potential memory leak in edid_load()
Date: Tue, 07 Aug 2012 20:01:59 +0200 [thread overview]
Message-ID: <50215817.6070009@osadl.org> (raw)
In-Reply-To: <1344342186-6561-1-git-send-email-khoroshilov@ispras.ru>
On 08/07/2012 02:23 PM, Alexey Khoroshilov wrote:
> Do not leak memory by updating pointer with potentially
> NULL realloc return value.
>
> Found by Linux Driver Verification project (linuxtesting.org).
Thanks, Alexey!
Reviewed-by: Carsten Emde <C.Emde@osadl.org>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> drivers/gpu/drm/drm_edid_load.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c
> index 66d4a28..0303935 100644
> --- a/drivers/gpu/drm/drm_edid_load.c
> +++ b/drivers/gpu/drm/drm_edid_load.c
> @@ -119,7 +119,7 @@ static int edid_load(struct drm_connector *connector, char *name,
> {
> const struct firmware *fw;
> struct platform_device *pdev;
> - u8 *fwdata = NULL, *edid;
> + u8 *fwdata = NULL, *edid, *new_edid;
> int fwsize, expected;
> int builtin = 0, err = 0;
> int i, valid_extensions = 0;
> @@ -195,12 +195,14 @@ static int edid_load(struct drm_connector *connector, char *name,
> "\"%s\" for connector \"%s\"\n", valid_extensions,
> edid[0x7e], name, connector_name);
> edid[0x7e] = valid_extensions;
> - edid = krealloc(edid, (valid_extensions + 1) * EDID_LENGTH,
> + new_edid = krealloc(edid, (valid_extensions + 1) * EDID_LENGTH,
> GFP_KERNEL);
> - if (edid == NULL) {
> + if (new_edid == NULL) {
> err = -ENOMEM;
> + kfree(edid);
> goto relfw_out;
> }
> + edid = new_edid;
> }
>
> connector->display_info.raw_edid = edid;
prev parent reply other threads:[~2012-08-07 18:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-07 12:23 [PATCH] drm/edid: Fix potential memory leak in edid_load() Alexey Khoroshilov
2012-08-07 18:01 ` Carsten Emde [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=50215817.6070009@osadl.org \
--to=c.emde@osadl.org \
--cc=airlied@linux.ie \
--cc=dri-devel@lists.freedesktop.org \
--cc=khoroshilov@ispras.ru \
--cc=ldv-project@ispras.ru \
--cc=linux-kernel@vger.kernel.org \
/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