Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9e50e35 authored by Dongliang Mu's avatar Dongliang Mu Committed by Greg Kroah-Hartman
Browse files

media: dvb-usb: fix uninit-value in vp702x_read_mac_addr



[ Upstream commit 797c061ad715a9a1480eb73f44b6939fbe3209ed ]

If vp702x_usb_in_op fails, the mac address is not initialized.
And vp702x_read_mac_addr does not handle this failure, which leads to
the uninit-value in dvb_usb_adapter_dvb_init.

Fix this by handling the failure of vp702x_usb_in_op.

Fixes: 786baecf ("[media] dvb-usb: move it to drivers/media/usb/dvb-usb")
Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 811cb972
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -294,16 +294,22 @@ static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
{
	u8 i, *buf;
	int ret;
	struct vp702x_device_state *st = d->priv;

	mutex_lock(&st->buf_mutex);
	buf = st->buf;
	for (i = 6; i < 12; i++)
		vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1, &buf[i - 6], 1);
	for (i = 6; i < 12; i++) {
		ret = vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1,
				       &buf[i - 6], 1);
		if (ret < 0)
			goto err;
	}

	memcpy(mac, buf, 6);
err:
	mutex_unlock(&st->buf_mutex);
	return 0;
	return ret;
}

static int vp702x_frontend_attach(struct dvb_usb_adapter *adap)