check the return value and pass the proper error code. Signed-off-by: F.A. SULAIMAN <asha.16@xxxxxxxxxxxxxxx> --- drivers/gpu/drm/udl/udl_connector.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c index cdc1c42e1669..857d2c97ef0e 100644 --- a/drivers/gpu/drm/udl/udl_connector.c +++ b/drivers/gpu/drm/udl/udl_connector.c @@ -23,7 +23,7 @@ static int udl_get_edid_block(void *data, u8 *buf, unsigned int block, read_buff = kmalloc(2, GFP_KERNEL); if (!read_buff) - return -1; + return -ENOMEM; for (i = 0; i < len; i++) { int bval = (i + block * EDID_LENGTH) << 8; @@ -31,11 +31,16 @@ static int udl_get_edid_block(void *data, u8 *buf, unsigned int block, usb_rcvctrlpipe(udl->udev, 0), (0x02), (0x80 | (0x02 << 5)), bval, 0xA1, read_buff, 2, HZ); - if (ret < 1) { + if (ret == 0) { + DRM_ERROR("Reading EDID block %d returned empty result\n", i); + kfree(read_buff); + return -EINVAL; + } else if (ret < 0) { DRM_ERROR("Read EDID byte %d failed err %x\n", i, ret); kfree(read_buff); - return -1; + return ret; } + buf[i] = read_buff[1]; } -- 2.17.1