From nobody Mon Feb 9 23:01:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152937687793279.80702625393974; Mon, 18 Jun 2018 19:54:37 -0700 (PDT) Received: from localhost ([::1]:38783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6mv-0004zn-49 for importer@patchew.org; Mon, 18 Jun 2018 22:54:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5ii-0002KY-56 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5ih-0000Fb-7s for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:46:08 -0400 Received: from mail-ot0-x244.google.com ([2607:f8b0:4003:c0f::244]:40776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5ih-0000FX-2p; Mon, 18 Jun 2018 21:46:07 -0400 Received: by mail-ot0-x244.google.com with SMTP id w9-v6so20746699otj.7; Mon, 18 Jun 2018 18:46:06 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id j196-v6sm8557604oib.14.2018.06.18.18.46.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=G4/CnrWRGeHzp/VLZBveCQgvdh57EOJOeTX51ClzTK0=; b=lTQhJKzkWvesDlBen8txLxU/G8wuvQe2RnB6/8s5NJF9Ol5Nb2fIJBsYlZuu31WQoI sAdncMZmiODCCoNC/1TPTn5VgbXy1jcpNXg8FIJx2SRBtnscM67bJAxrpmV5BLe8QOfr ft34lNlMv7UFMkJR5iYYDuYaE4eT2N6fi2H8WBU8hklqiou9zTqmQE5X3IINJWj3r5cm b71LfchQajg53gY27vDhFlwaVsDdasnrQgWTH+7nm8D4RV6PZne0YYAZu58q0YtktTt1 h5a5Na9K+sP0O0u1bP2d901MKArXz/46UtvkTCtjXxQl5KIl0anFMzW+yeaNdggYiwV2 zseA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=G4/CnrWRGeHzp/VLZBveCQgvdh57EOJOeTX51ClzTK0=; b=KYVUToUu1nt31TT1FzJ9oE/haOvvl3kmWggrYyVD/Rb0ShmgXOpKDghvsWppeE0HlD zEI7nrbfP2W4TEeVP6bKGR0vzEmIAESqsDUbXckGmY73eRcYv1z71LqaWYHHkHNa1aJw XyGL/ELbanIaBcfFUTi+IAvNGBwzFO8vVk5myGlvZLblgfsjqe9jWc5r80nWLSMRWbmo bnmR+rgXttqBOHxXJurpupxt+TA21ufuHWzj7uOSjW5BJg08Jk3mX9CW2c1Hs4c4bkVJ tWeAhLhjFG/ubxpsdnJQT0baQfqdrjjo5tARRH/xXO1ZXWqSsTYtKCERQU6e6hI26SRJ mqIA== X-Gm-Message-State: APt69E1i9N7y1hAAZXNdjoV41ABniTu4xbolH1wlZ5K4hTrfgG/VZut0 IsFqp9YDhms0+bjjUIj5pCuD/kmp21g= X-Google-Smtp-Source: ADUXVKKKVwl+++71hTFWvV0RoOP3R1uGiu0p+0bcJxZfIoTigC/qLGz1qRq3S0B9ljlJAMOj583pUQ== X-Received: by 2002:a9d:3835:: with SMTP id i50-v6mr9651942otc.382.1529372765990; Mon, 18 Jun 2018 18:46:05 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:42:21 -0500 Message-Id: <20180619014319.28272-56-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c0f::244 Subject: [Qemu-devel] [PATCH 055/113] vfio-ccw: fix memory leaks in vfio_ccw_realize() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz If the subchannel is already attached or if vfio_get_device() fails, the code jumps to the 'out_device_err' label and doesn't free the string it has just allocated. The code should be reworked so that vcdev->vdev.name only gets set when the device has been attached, and freed when it is about to be detached. This could be achieved with the addition of a vfio_ccw_get_device() function that would be the counterpart of vfio_put_device(). But this is a more elaborate cleanup that should be done in a follow-up. For now, let's just add calls to g_free() on the buggy error paths. Signed-off-by: Greg Kurz Message-Id: <152311222681.203086.8874800175539040298.stgit@bahia> Signed-off-by: Cornelia Huck (cherry picked from commit be4d026f645eb31078e08d431c93a898b895024e) Signed-off-by: Michael Roth --- hw/vfio/ccw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 636729c03d..c74e107a04 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -357,11 +357,13 @@ static void vfio_ccw_realize(DeviceState *dev, Error = **errp) if (strcmp(vbasedev->name, vcdev->vdev.name) =3D=3D 0) { error_setg(&err, "vfio: subchannel %s has already been attache= d", vcdev->vdev.name); + g_free(vcdev->vdev.name); goto out_device_err; } } =20 if (vfio_get_device(group, cdev->mdevid, &vcdev->vdev, &err)) { + g_free(vcdev->vdev.name); goto out_device_err; } =20 --=20 2.11.0