Skip to content

Commit f7b83b9

Browse files
khoroshilovairlied
authored andcommitted
drm/edid: Fix potential memory leak in edid_load()
Do not leak memory by updating pointer with potentially NULL realloc return value. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Reviewed-by: Carsten Emde <C.Emde@osadl.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 959f724 commit f7b83b9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/gpu/drm/drm_edid_load.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static int edid_load(struct drm_connector *connector, char *name,
119119
{
120120
const struct firmware *fw;
121121
struct platform_device *pdev;
122-
u8 *fwdata = NULL, *edid;
122+
u8 *fwdata = NULL, *edid, *new_edid;
123123
int fwsize, expected;
124124
int builtin = 0, err = 0;
125125
int i, valid_extensions = 0;
@@ -195,12 +195,14 @@ static int edid_load(struct drm_connector *connector, char *name,
195195
"\"%s\" for connector \"%s\"\n", valid_extensions,
196196
edid[0x7e], name, connector_name);
197197
edid[0x7e] = valid_extensions;
198-
edid = krealloc(edid, (valid_extensions + 1) * EDID_LENGTH,
198+
new_edid = krealloc(edid, (valid_extensions + 1) * EDID_LENGTH,
199199
GFP_KERNEL);
200-
if (edid == NULL) {
200+
if (new_edid == NULL) {
201201
err = -ENOMEM;
202+
kfree(edid);
202203
goto relfw_out;
203204
}
205+
edid = new_edid;
204206
}
205207

206208
connector->display_info.raw_edid = edid;

0 commit comments

Comments
 (0)