Skip to content

Commit b99bdf1

Browse files
pskrgaggregkh
authored andcommitted
media: mxl111sf: change mutex_init() location
commit 44870a9 upstream. Syzbot reported, that mxl111sf_ctrl_msg() uses uninitialized mutex. The problem was in wrong mutex_init() location. Previous mutex_init(&state->msg_lock) call was in ->init() function, but dvb_usbv2_init() has this order of calls: dvb_usbv2_init() dvb_usbv2_adapter_init() dvb_usbv2_adapter_frontend_init() props->frontend_attach() props->init() Since mxl111sf_* devices call mxl111sf_ctrl_msg() in ->frontend_attach() internally we need to initialize state->msg_lock before frontend_attach(). To achieve it, ->probe() call added to all mxl111sf_* devices, which will simply initiaize mutex. Reported-and-tested-by: syzbot+5ca0bf339f13c4243001@syzkaller.appspotmail.com Fixes: 8572211 ("[media] mxl111sf: convert to new DVB USB") Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0413f7a commit b99bdf1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/media/usb/dvb-usb-v2/mxl111sf.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,6 @@ static int mxl111sf_init(struct dvb_usb_device *d)
931931
.len = sizeof(eeprom), .buf = eeprom },
932932
};
933933

934-
mutex_init(&state->msg_lock);
935-
936934
ret = get_chip_info(state);
937935
if (mxl_fail(ret))
938936
pr_err("failed to get chip info during probe");
@@ -1074,6 +1072,14 @@ static int mxl111sf_get_stream_config_dvbt(struct dvb_frontend *fe,
10741072
return 0;
10751073
}
10761074

1075+
static int mxl111sf_probe(struct dvb_usb_device *dev)
1076+
{
1077+
struct mxl111sf_state *state = d_to_priv(dev);
1078+
1079+
mutex_init(&state->msg_lock);
1080+
return 0;
1081+
}
1082+
10771083
static struct dvb_usb_device_properties mxl111sf_props_dvbt = {
10781084
.driver_name = KBUILD_MODNAME,
10791085
.owner = THIS_MODULE,
@@ -1083,6 +1089,7 @@ static struct dvb_usb_device_properties mxl111sf_props_dvbt = {
10831089
.generic_bulk_ctrl_endpoint = 0x02,
10841090
.generic_bulk_ctrl_endpoint_response = 0x81,
10851091

1092+
.probe = mxl111sf_probe,
10861093
.i2c_algo = &mxl111sf_i2c_algo,
10871094
.frontend_attach = mxl111sf_frontend_attach_dvbt,
10881095
.tuner_attach = mxl111sf_attach_tuner,
@@ -1124,6 +1131,7 @@ static struct dvb_usb_device_properties mxl111sf_props_atsc = {
11241131
.generic_bulk_ctrl_endpoint = 0x02,
11251132
.generic_bulk_ctrl_endpoint_response = 0x81,
11261133

1134+
.probe = mxl111sf_probe,
11271135
.i2c_algo = &mxl111sf_i2c_algo,
11281136
.frontend_attach = mxl111sf_frontend_attach_atsc,
11291137
.tuner_attach = mxl111sf_attach_tuner,
@@ -1165,6 +1173,7 @@ static struct dvb_usb_device_properties mxl111sf_props_mh = {
11651173
.generic_bulk_ctrl_endpoint = 0x02,
11661174
.generic_bulk_ctrl_endpoint_response = 0x81,
11671175

1176+
.probe = mxl111sf_probe,
11681177
.i2c_algo = &mxl111sf_i2c_algo,
11691178
.frontend_attach = mxl111sf_frontend_attach_mh,
11701179
.tuner_attach = mxl111sf_attach_tuner,
@@ -1233,6 +1242,7 @@ static struct dvb_usb_device_properties mxl111sf_props_atsc_mh = {
12331242
.generic_bulk_ctrl_endpoint = 0x02,
12341243
.generic_bulk_ctrl_endpoint_response = 0x81,
12351244

1245+
.probe = mxl111sf_probe,
12361246
.i2c_algo = &mxl111sf_i2c_algo,
12371247
.frontend_attach = mxl111sf_frontend_attach_atsc_mh,
12381248
.tuner_attach = mxl111sf_attach_tuner,
@@ -1311,6 +1321,7 @@ static struct dvb_usb_device_properties mxl111sf_props_mercury = {
13111321
.generic_bulk_ctrl_endpoint = 0x02,
13121322
.generic_bulk_ctrl_endpoint_response = 0x81,
13131323

1324+
.probe = mxl111sf_probe,
13141325
.i2c_algo = &mxl111sf_i2c_algo,
13151326
.frontend_attach = mxl111sf_frontend_attach_mercury,
13161327
.tuner_attach = mxl111sf_attach_tuner,
@@ -1381,6 +1392,7 @@ static struct dvb_usb_device_properties mxl111sf_props_mercury_mh = {
13811392
.generic_bulk_ctrl_endpoint = 0x02,
13821393
.generic_bulk_ctrl_endpoint_response = 0x81,
13831394

1395+
.probe = mxl111sf_probe,
13841396
.i2c_algo = &mxl111sf_i2c_algo,
13851397
.frontend_attach = mxl111sf_frontend_attach_mercury_mh,
13861398
.tuner_attach = mxl111sf_attach_tuner,

0 commit comments

Comments
 (0)