media: dvb: digitv: remove unused array element 0
PATCH 1/1 media: dvb: digitv: remove unused array element 0
The first element of the key array is not used. Remove it, and along with it a uninitialized memory read.
This should fix the rc debug message.
--- drivers/media/usb/dvb-usb/digitv.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/media/usb/dvb-usb/digitv.c +7 -7
@@ -231,13 +231,13 @@ static struct rc_map_table rc_map_digitv_table[] = {static int digitv_rc_query (struct dvb_usb_device *d,u32 *event,int *state) {int ret, i; -u8 key[5 ]; +u8 key[4 ];u8 b[4 ] = {0 }; *event =0 ; *state =REMOTE_NO_KEY_PRESSED ; - ret =digitv_ctrl_msg (d,USB_READ_REMOTE ,0 ,NULL ,0 , &key[1 ],4 ); + ret =digitv_ctrl_msg (d,USB_READ_REMOTE ,0 ,NULL ,0 , key,4 );if (ret)return ret;
@@ -248,20 +248,20 @@ static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)return ret;/* if something is inside the buffer, simulate key press */ -if (key[1 ] !=0 ) +if (key[0 ] !=0 ) {for (i =0 ; i < d->props.rc.legacy.rc_map_size; i++) { -if (rc5_custom (&d->props.rc.legacy.rc_map_table[i]) == key[1 ] && -rc5_data (&d->props.rc.legacy.rc_map_table[i]) == key[2 ]) { +if (rc5_custom (&d->props.rc.legacy.rc_map_table[i]) == key[0 ] && +rc5_data (&d->props.rc.legacy.rc_map_table[i]) == key[1 ]) { *event = d->props.rc.legacy.rc_map_table[i].keycode; *state =REMOTE_KEY_PRESSED ;return 0 ; } } + +deb_rc ("key: %*ph\n" ,4 , key); } -if (key[0 ] !=0 ) -deb_rc ("key: %*ph\n" ,5 , key);return 0 ; }
Signature · 1 line
2.24.1
kbuild test robot
build botI love your patch! Perhaps something to improve:
Hi Sean,
I love your patch! Perhaps something to improve:
[auto build test WARNING on linuxtv-media/master]
[also build test WARNING on v5.6-rc6 next-20200320]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Sean-Young/media-dvb-digitv-remove-unused-array-element-0/20200313-024740 base: git://linuxtv.org/media_tree.git master
If you fix the issue, kindly add following tag
smatch warnings:drivers/media/usb/dvb-usb/digitv.c:262 digitv_rc_query() warn: inconsistent indenting
vim +262 drivers/media/usb/dvb-usb/digitv.c
230
231 static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
232 {
233 int ret, i;
234 u8 key[4];
235 u8 b[4] = { 0 };
236
237 *event = 0;
238 *state = REMOTE_NO_KEY_PRESSED;
239
240 ret = digitv_ctrl_msg(d, USB_READ_REMOTE, 0, NULL, 0, key, 4);
241 if (ret)
242 return ret;
243
244 /* Tell the device we've read the remote. Not sure how necessary
245 this is, but the Nebula SDK does it. */
246 ret = digitv_ctrl_msg(d, USB_WRITE_REMOTE, 0, b, 4, NULL, 0);
247 if (ret)
248 return ret;
249
250 /* if something is inside the buffer, simulate key press */
251 if (key[0] != 0)
252 {
253 for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) {
254 if (rc5_custom(&d->props.rc.legacy.rc_map_table[i]) == key[0] &&
255 rc5_data(&d->props.rc.legacy.rc_map_table[i]) == key[1]) {
256 *event = d->props.rc.legacy.rc_map_table[i].keycode;
257 *state = REMOTE_KEY_PRESSED;
258 return 0;
259 }
260 }
261
> 262 deb_rc("key: %*ph\n", 4, key); 263 }
264
265 return 0;
266 }
267
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org