From: Joe Perches <joe@perches.com>
To: Alexandru Gheorghiu <gheorghiuandru@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
David Airlie <airlied@linux.ie>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: gpu: drm: i915: Replaced calls to kmalloc & memcpy with kmemdup
Date: Mon, 11 Mar 2013 14:19:34 -0700 [thread overview]
Message-ID: <1363036774.2056.59.camel@joe-AO722> (raw)
In-Reply-To: <1363034382-22752-1-git-send-email-gheorghiuandru@gmail.com>
On Mon, 2013-03-11 at 22:39 +0200, Alexandru Gheorghiu wrote:
> Replaced calls to kmalloc followed by memcpy with a single call to kmemdup.
> Also removed a now redundant if statement.
[]
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
[]
> @@ -2335,11 +2335,8 @@ intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
> return NULL;
>
> size = (intel_connector->edid->extensions + 1) * EDID_LENGTH;
> - edid = kmalloc(size, GFP_KERNEL);
> - if (!edid)
> - return NULL;
> + edid = kmemdup(intel_connector->edid, size, GFP_KERNEL);
>
> - memcpy(edid, intel_connector->edid, size);
> return edid;
> }
>
Might as well get rid of the stack variable edid altogether.
Maybe get rid of size too and use:
if (intel_connector->edid) {
/* invalid edid */
if (IS_ERR(intel_connector->edid))
return NULL;
return kmemdup(intel_connector->edid,
(intel_connector->edid->extensions + 1) * EDID_LENGTH,
GFP_KERNEL);
}
next prev parent reply other threads:[~2013-03-11 21:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-11 20:39 Alexandru Gheorghiu
2013-03-11 21:19 ` Joe Perches [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-03-11 19:30 Alexandru Gheorghiu
2013-03-11 20:25 ` Josh Triplett
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=1363036774.2056.59.camel@joe-AO722 \
--to=joe@perches.com \
--cc=airlied@linux.ie \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gheorghiuandru@gmail.com \
--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
all inboxes | Powered by JetHome®