fixes: input error handling & audio segfault
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABCgAGBQJeezlSAAoJEEy22O7T6HE4gckP/jTmBjY9HsuULdMemjx2E+JC mijgg7odswxhG/CS6mUwtpioyeZ01mAwsWwIQ3V4LHGc+1NIy5I1OsZE+Na79Yyp Z8YN1LDDLA9jnIo1bYa2fHjenWQh/6kopKK2lbmsUUEsurA7+nUpGrM5z/32MvKY Z+yItRbIVuktkeWr/bzndm2kreo1LsX0a/pEzlBDbnAtxX1tkRnKM9RQ8kVKk31W VQ0bFyVgoh9CpQK9XTpmvESSpezL2OUAxWfhHz6edPR7STQPIL/hwgLCkcKr/uRH E+0hKwXg41y/7c2hBnQSFMarJkik66MDz+pccLs0hwXNXfV7uGLyPhBYOm1JtRKy 7G8ek8jYhHSG/riQZhrfUwHCfv79uwwZHPhe6Inhj78eJRt0LmPhYgtR+Gw5d+V3 Wzw1ua1A9xzBJveKgnfUzLxOmxHcpBrIBGFjIquwjN+p1nKtq/zc3BdsPMP5Yd+8 Z9A7HwClZjDm8SKcYm4LSIhnsN7CPby1phEqq+Co5R1NcKYJZQYnyuR9OLCUvw9e zggxPxE/FJcEtUTA36OIZAAHuBNJQBsYUjLA4p4Kzsq/8mPGW1ZxZgSIjdGm47mD Mgo0ItrMKagdbErV8249kyspHF8UHP2f27RxQU2p3BThKgqdamK7Aikg7LDbRiPD ukCgh6MNbhMNgynQq5Xn =MBQp -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kraxel/tags/fixes-20200325-pull-request' into staging fixes: input error handling & audio segfault # gpg: Signature made Wed 25 Mar 2020 10:58:26 GMT # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/fixes-20200325-pull-request: hw/audio/fmopl: fix segmentation fault ui/input-linux: Do not ignore ioctl() return value Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
042abffc5e
@ -627,6 +627,7 @@ static int OPLOpenTable( void )
|
||||
free(AMS_TABLE);
|
||||
return 0;
|
||||
}
|
||||
ENV_CURVE = g_new(int32_t, 2 * EG_ENT + 1);
|
||||
/* make total level table */
|
||||
for (t = 0;t < EG_ENT-1 ;t++){
|
||||
rate = ((1<<TL_BITS)-1)/pow(10,EG_STEP*t/20); /* dB -> voltage */
|
||||
@ -694,6 +695,7 @@ static int OPLOpenTable( void )
|
||||
|
||||
static void OPLCloseTable( void )
|
||||
{
|
||||
g_free(ENV_CURVE);
|
||||
free(TL_TABLE);
|
||||
free(SIN_TABLE);
|
||||
free(AMS_TABLE);
|
||||
@ -1090,7 +1092,6 @@ FM_OPL *OPLCreate(int clock, int rate)
|
||||
OPL->clock = clock;
|
||||
OPL->rate = rate;
|
||||
OPL->max_ch = max_ch;
|
||||
ENV_CURVE = g_new(int32_t, 2 * EG_ENT + 1);
|
||||
/* init grobal tables */
|
||||
OPL_initialize(OPL);
|
||||
/* reset chip */
|
||||
@ -1128,7 +1129,6 @@ void OPLDestroy(FM_OPL *OPL)
|
||||
#endif
|
||||
OPL_UnLockTable();
|
||||
free(OPL);
|
||||
g_free(ENV_CURVE);
|
||||
}
|
||||
|
||||
/* ---------- Option handlers ---------- */
|
||||
|
@ -334,13 +334,15 @@ static void input_linux_complete(UserCreatable *uc, Error **errp)
|
||||
|
||||
rc = ioctl(il->fd, EVIOCGBIT(0, sizeof(evtmap)), &evtmap);
|
||||
if (rc < 0) {
|
||||
error_setg(errp, "%s: failed to read event bits", il->evdev);
|
||||
goto err_close;
|
||||
goto err_read_event_bits;
|
||||
}
|
||||
|
||||
if (evtmap & (1 << EV_REL)) {
|
||||
relmap = 0;
|
||||
rc = ioctl(il->fd, EVIOCGBIT(EV_REL, sizeof(relmap)), &relmap);
|
||||
if (rc < 0) {
|
||||
goto err_read_event_bits;
|
||||
}
|
||||
if (relmap & (1 << REL_X)) {
|
||||
il->has_rel_x = true;
|
||||
}
|
||||
@ -349,12 +351,25 @@ static void input_linux_complete(UserCreatable *uc, Error **errp)
|
||||
if (evtmap & (1 << EV_ABS)) {
|
||||
absmap = 0;
|
||||
rc = ioctl(il->fd, EVIOCGBIT(EV_ABS, sizeof(absmap)), &absmap);
|
||||
if (rc < 0) {
|
||||
goto err_read_event_bits;
|
||||
}
|
||||
if (absmap & (1 << ABS_X)) {
|
||||
il->has_abs_x = true;
|
||||
rc = ioctl(il->fd, EVIOCGABS(ABS_X), &absinfo);
|
||||
if (rc < 0) {
|
||||
error_setg(errp, "%s: failed to get get absolute X value",
|
||||
il->evdev);
|
||||
goto err_close;
|
||||
}
|
||||
il->abs_x_min = absinfo.minimum;
|
||||
il->abs_x_max = absinfo.maximum;
|
||||
rc = ioctl(il->fd, EVIOCGABS(ABS_Y), &absinfo);
|
||||
if (rc < 0) {
|
||||
error_setg(errp, "%s: failed to get get absolute Y value",
|
||||
il->evdev);
|
||||
goto err_close;
|
||||
}
|
||||
il->abs_y_min = absinfo.minimum;
|
||||
il->abs_y_max = absinfo.maximum;
|
||||
}
|
||||
@ -363,7 +378,14 @@ static void input_linux_complete(UserCreatable *uc, Error **errp)
|
||||
if (evtmap & (1 << EV_KEY)) {
|
||||
memset(keymap, 0, sizeof(keymap));
|
||||
rc = ioctl(il->fd, EVIOCGBIT(EV_KEY, sizeof(keymap)), keymap);
|
||||
if (rc < 0) {
|
||||
goto err_read_event_bits;
|
||||
}
|
||||
rc = ioctl(il->fd, EVIOCGKEY(sizeof(keystate)), keystate);
|
||||
if (rc < 0) {
|
||||
error_setg(errp, "%s: failed to get global key state", il->evdev);
|
||||
goto err_close;
|
||||
}
|
||||
for (i = 0; i < KEY_CNT; i++) {
|
||||
if (keymap[i / 8] & (1 << (i % 8))) {
|
||||
if (linux_is_button(i)) {
|
||||
@ -390,6 +412,9 @@ static void input_linux_complete(UserCreatable *uc, Error **errp)
|
||||
il->initialized = true;
|
||||
return;
|
||||
|
||||
err_read_event_bits:
|
||||
error_setg(errp, "%s: failed to read event bits", il->evdev);
|
||||
|
||||
err_close:
|
||||
close(il->fd);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user