From nobody Fri Apr 19 20:21:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585134597; cv=none; d=zohomail.com; s=zohoarc; b=ETUVMXB6ETy+IyUevg38TOjUsBTsaMkkTnIqOrPL/W0CJitcmQ7oZzuxm3eFj5piZeO7jmjOYOgQnJQLWT7Hv99Kd3vsKmcnGG7ptFTprFyzT3e7olMlPZKlBopnHu9+felvb3GtulLibT0baAEjELi9l6XAYaSIutR7pwnbfzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585134597; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gB4woRW/Nzbg26Mg/GNQXB3WuMZDhaHiX1vwdbRO+tE=; b=eNZJ9u2eJk26VTDxF9wv7WIgrNQSI0b6HAKe7ZnrtcFYnIgXpZlRgECJnrcgNNdMdMcIMQQ6nE6Tdt3LJ9mzzGbtCCEIgGh+Z0yrEEd7UUAcDHBAxV147Eup0H4XcD0YYO2zNlnnagDsl9gJu9ibE7pa/aMJUZMZ9szjENCXlEk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585134597954299.06882014446546; Wed, 25 Mar 2020 04:09:57 -0700 (PDT) Received: from localhost ([::1]:34452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH3v0-0005Jc-Gm for importer@patchew.org; Wed, 25 Mar 2020 07:09:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37966) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH3kM-0000MR-3A for qemu-devel@nongnu.org; Wed, 25 Mar 2020 06:58:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jH3kJ-0006j2-PP for qemu-devel@nongnu.org; Wed, 25 Mar 2020 06:58:53 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:40839) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jH3kJ-0006iO-Kx for qemu-devel@nongnu.org; Wed, 25 Mar 2020 06:58:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-200-Bs1AHv8CNrGzuRpjMkw3Eg-1; Wed, 25 Mar 2020 06:58:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E8878018B1 for ; Wed, 25 Mar 2020 10:58:48 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1BDF60C18; Wed, 25 Mar 2020 10:58:44 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D87DA9D43; Wed, 25 Mar 2020 11:58:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585133931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gB4woRW/Nzbg26Mg/GNQXB3WuMZDhaHiX1vwdbRO+tE=; b=igc7A8GKoccufNrgXmxpFNZ9FTUHJGGX4IvluM7a+FrAJMeu4WXyS3K0XZVFrO3itVjGOb 2YDpKEyTHkHWrwwiK5zM139qEqtzWFtCpGBQAVfJWw34LMYCzXRNDFtlXNhKfEyZE0m/DN 0RWZJFhBNCJQ38R5Offl6DGFnofDbYY= X-MC-Unique: Bs1AHv8CNrGzuRpjMkw3Eg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 1/2] ui/input-linux: Do not ignore ioctl() return value Date: Wed, 25 Mar 2020 11:58:42 +0100 Message-Id: <20200325105843.17387-2-kraxel@redhat.com> In-Reply-To: <20200325105843.17387-1-kraxel@redhat.com> References: <20200325105843.17387-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Philippe Mathieu-Daud=C3=A9 Fix warnings reported by Clang static code analyzer: CC ui/input-linux.o ui/input-linux.c:343:9: warning: Value stored to 'rc' is never read rc =3D ioctl(il->fd, EVIOCGBIT(EV_REL, sizeof(relmap)), &relmap); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ui/input-linux.c:351:9: warning: Value stored to 'rc' is never read rc =3D ioctl(il->fd, EVIOCGBIT(EV_ABS, sizeof(absmap)), &absmap); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ui/input-linux.c:354:13: warning: Value stored to 'rc' is never read rc =3D ioctl(il->fd, EVIOCGABS(ABS_X), &absinfo); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ui/input-linux.c:357:13: warning: Value stored to 'rc' is never read rc =3D ioctl(il->fd, EVIOCGABS(ABS_Y), &absinfo); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ui/input-linux.c:365:9: warning: Value stored to 'rc' is never read rc =3D ioctl(il->fd, EVIOCGBIT(EV_KEY, sizeof(keymap)), keymap); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ui/input-linux.c:366:9: warning: Value stored to 'rc' is never read rc =3D ioctl(il->fd, EVIOCGKEY(sizeof(keystate)), keystate); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Darren Kenny Message-id: 20200322161219.17757-1-philmd@redhat.com Signed-off-by: Gerd Hoffmann --- ui/input-linux.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/ui/input-linux.c b/ui/input-linux.c index a7b280b25b98..ef37b14d6f22 100644 --- a/ui/input-linux.c +++ b/ui/input-linux.c @@ -334,13 +334,15 @@ static void input_linux_complete(UserCreatable *uc, E= rror **errp) =20 rc =3D 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; } =20 if (evtmap & (1 << EV_REL)) { relmap =3D 0; rc =3D 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 =3D true; } @@ -349,12 +351,25 @@ static void input_linux_complete(UserCreatable *uc, E= rror **errp) if (evtmap & (1 << EV_ABS)) { absmap =3D 0; rc =3D 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 =3D true; rc =3D 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 =3D absinfo.minimum; il->abs_x_max =3D absinfo.maximum; rc =3D 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 =3D absinfo.minimum; il->abs_y_max =3D absinfo.maximum; } @@ -363,7 +378,14 @@ static void input_linux_complete(UserCreatable *uc, Er= ror **errp) if (evtmap & (1 << EV_KEY)) { memset(keymap, 0, sizeof(keymap)); rc =3D ioctl(il->fd, EVIOCGBIT(EV_KEY, sizeof(keymap)), keymap); + if (rc < 0) { + goto err_read_event_bits; + } rc =3D ioctl(il->fd, EVIOCGKEY(sizeof(keystate)), keystate); + if (rc < 0) { + error_setg(errp, "%s: failed to get global key state", il->evd= ev); + goto err_close; + } for (i =3D 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, Err= or **errp) il->initialized =3D true; return; =20 +err_read_event_bits: + error_setg(errp, "%s: failed to read event bits", il->evdev); + err_close: close(il->fd); return; --=20 2.18.2 From nobody Fri Apr 19 20:21:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1585134083; cv=none; d=zohomail.com; s=zohoarc; b=YzrzjLC313b0YEkMKfuq9HYZfzdRdO7KFvfzo7BXXKsCMCgzc00WdKHWgTIWmNmmwEbM/LS+lx/DHZEKRkhxGEvOAMCsfcfPUt/bNnIB8ixeQqTkBN1yW8vhEv4LAeM2taFOuZqCJxsXLGK/+gNGUoH5AaU416lMzqd6HRRv25g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585134083; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zFiF4MhS5uVnJJBp8JB56GIwKfGYSvvTknJEdz9kuOc=; b=B1CnCdYEzx6uGmki/3gttbvQey1QeGepCl5ybFdKL6iyEunRrfb6j4LDBBR4NdiQ6mo1ug+lpbFFhkbi2CRzOCgmur8MdhjUylqGD5B3EN09ZZC1+NpFJbm6/SSpa+ixQR6UwKBxgE3tnkM6S2ZnbC5uH+VaZWynWpHdlUdw1XA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585134083463881.1624560114393; Wed, 25 Mar 2020 04:01:23 -0700 (PDT) Received: from localhost ([::1]:34338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH3mj-000335-6F for importer@patchew.org; Wed, 25 Mar 2020 07:01:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37955) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jH3kK-0000Kz-J5 for qemu-devel@nongnu.org; Wed, 25 Mar 2020 06:58:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jH3kJ-0006iI-Bq for qemu-devel@nongnu.org; Wed, 25 Mar 2020 06:58:52 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:46408) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jH3kJ-0006hq-71 for qemu-devel@nongnu.org; Wed, 25 Mar 2020 06:58:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-88-CeU_V0ngNZ-VsfH7DfjtWw-1; Wed, 25 Mar 2020 06:58:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC7DF189D6D2; Wed, 25 Mar 2020 10:58:47 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6D9796FAA; Wed, 25 Mar 2020 10:58:44 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E0EC09D13; Wed, 25 Mar 2020 11:58:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585133930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zFiF4MhS5uVnJJBp8JB56GIwKfGYSvvTknJEdz9kuOc=; b=hKiLqM8GEOJEEpHxSxmGLlWbVzyk7I2X2Moh32z2gObVUuwNZuS7/RPOP9aexKa6J9qN7F 0qRVKbtJo9q3a0cADR5aevBiVjpdeC0KW9XcmUP9uxNkLyBW8whaE3DGPX4umFiwNc2D3E 2pPw28kbCOfVcwopva8zBJiYiLsPRvc= X-MC-Unique: CeU_V0ngNZ-VsfH7DfjtWw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 2/2] hw/audio/fmopl: fix segmentation fault Date: Wed, 25 Mar 2020 11:58:43 +0100 Message-Id: <20200325105843.17387-3-kraxel@redhat.com> In-Reply-To: <20200325105843.17387-1-kraxel@redhat.com> References: <20200325105843.17387-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Volker R=C3=BCmelin Current code allocates the memory for ENV_CURVE too late. Move allocation to OPLOpenTable() and deallocation to OPLCloseTable(). To reproduce the bug start qemu with -soundhw adlib. Fixes 2eea51bd01 "hw/audio/fmopl: Move ENV_CURVE to .heap to save 32KiB of .bss" Signed-off-by: Volker R=C3=BCmelin Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20200324061855.5951-1-vr_qemu@t-online.de Signed-off-by: Gerd Hoffmann --- hw/audio/fmopl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/audio/fmopl.c b/hw/audio/fmopl.c index 356d4dfbcaa6..8a71a569fab0 100644 --- a/hw/audio/fmopl.c +++ b/hw/audio/fmopl.c @@ -627,6 +627,7 @@ static int OPLOpenTable( void ) free(AMS_TABLE); return 0; } + ENV_CURVE =3D g_new(int32_t, 2 * EG_ENT + 1); /* make total level table */ for (t =3D 0;t < EG_ENT-1 ;t++){ rate =3D ((1< voltage */ @@ -694,6 +695,7 @@ static int OPLOpenTable( void ) =20 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 =3D clock; OPL->rate =3D rate; OPL->max_ch =3D max_ch; - ENV_CURVE =3D 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); } =20 /* ---------- Option handlers ---------- */ --=20 2.18.2