From nobody Sat Nov 23 21:35:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1731344688; cv=none; d=zohomail.com; s=zohoarc; b=Vob8BdiNbSkBjXT/YfKrO5sAJg3fGOJToBD2p6Ssv26cuUUpftEfbtshlj4AbHxbc0elRtrpN6ViYMgm0Y7eiBQqUL4FPA8Z5iqJoFCTzG7F3zJP41IzdnHEyIw/H7YWemmfTnbX/F6c/i3xGuTSe1XFJFnzW6WXjmNSQg8849o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1731344688; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aswoOKXvIzBRThw5Im2BrT+a+DMSnACXRZbpsdUuO5Y=; b=mQZtTLO6Qbl1+7S7KsQ22K0JXklurt+sUa2ysgypthycbOj9LBszYmT3OvKZw3hj4Uq2pA7gIQFJbXIs3DXpgODE9VAwiDkAf2V+GMLY3BaVsMXJ1vwXSapA33KYMTSEfB6NmaIY3aONmH2Y3IJmdiZyuMxP1Z5fcFxDxdaVy+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1731344688501444.5256219595045; Mon, 11 Nov 2024 09:04:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tAXpW-0005vu-8e; Mon, 11 Nov 2024 12:03:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tAXpP-0005ut-Pv for qemu-devel@nongnu.org; Mon, 11 Nov 2024 12:03:51 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tAXpO-0007hy-8P for qemu-devel@nongnu.org; Mon, 11 Nov 2024 12:03:51 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4316cce103dso59938345e9.3 for ; Mon, 11 Nov 2024 09:03:49 -0800 (PST) Received: from localhost.localdomain (vau06-h02-176-184-43-163.dsl.sta.abo.bbox.fr. [176.184.43.163]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381eda04049sm13204861f8f.93.2024.11.11.09.03.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 11 Nov 2024 09:03:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731344629; x=1731949429; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aswoOKXvIzBRThw5Im2BrT+a+DMSnACXRZbpsdUuO5Y=; b=Cg4eMBivePnketDBT9lL/asao4W7n6JHmVun+i26PH/N85TD4ac7EsVRfQSTHpyNNV y/BWlQM1gjzrHJKeko6sjlcfibJxotZ9aMbAIW2thnjV3yhHu+zTifYQkCU7o591cGOT RZ+WG1cBoA19Y/dq+dFTPrXBInpUBQJi9OUrvPfjxOsaSYO5XLJEEsxLVabpCM9uE9+N Gzif1bclBsBWvAZZLZxFOn+tN0TKfwrTyG9DUdRwre1SI30ttGuucqUX3ZdcAVAXClvL 6QM4OEoH1nV5tyhJlDqGiRgKtEeAH94zb7tr+JSNnxh0agL8K8UAGkD26SY7Hh4xismx eoIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731344629; x=1731949429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aswoOKXvIzBRThw5Im2BrT+a+DMSnACXRZbpsdUuO5Y=; b=JMYU83cNW3ukD+rmAgSnYWmLEBTO0C9gNkek8leQiZWau8PGdQ3ASb4Mll+XIeEPyI xgPltT9RNATjP05mAVmZY2+X5urhSrTwi6mx+U8r7NIUdC3FUfNv5KN2DcnIGkElLKoO 1K3GdgHFY9aJnRIKkBgGrxmA9OWH7sS+hmC/TljWXMmHoVSn/oCE0jauTF0fsverUsvc Gr7KosAJ/9oZFlC/yUeqy5frMWYghvI+kchSHa82RY1sLFyDutfnVvNsTnGWfyvehAAc dyW5ZCOMvQbCe28deXarl7boMWsn0ebrWM93SOuz+oIArk8WI2CPIBvNREv+wuBolzDU q5VQ== X-Forwarded-Encrypted: i=1; AJvYcCUCD0b7wrnUEv3QMGLd6/w5OABwGtkDnIxp5orv3e3dMrhTKPobLBk9CtrwRNbwlj39Hch1HqUBGab4@nongnu.org X-Gm-Message-State: AOJu0YziVGma0YHv+Wjo3WZIQEyeGvoEYPPsmhlXghhnPA8tE+IYsBqG 2mqDZr95ms3wzzwwIFSDn+WaalzFBgbFCvXsAt6rvkQm0Gu14149Adi5nfyYMvE= X-Google-Smtp-Source: AGHT+IFyB1rBJo9m1u2KgkUHXHd8dtIfcGq35meJPcGKk1gaswaJ/5OlR7o4b8T8XeMOdCICssJ5Vw== X-Received: by 2002:a05:600c:524b:b0:42b:ac3d:3abc with SMTP id 5b1f17b1804b1-432b7518c59mr141503645e9.24.1731344628453; Mon, 11 Nov 2024 09:03:48 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Fabiano Rosas , qemu-devel@nongnu.org Cc: Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/2] block: Fix leak in send_qmp_error_event Date: Mon, 11 Nov 2024 18:03:33 +0100 Message-ID: <20241111170333.43833-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111170333.43833-1-philmd@linaro.org> References: <20241111170333.43833-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1731344690757116600 From: Fabiano Rosas ASAN detected a leak when running the ahci-test /ahci/io/dma/lba28/retry: Direct leak of 35 byte(s) in 1 object(s) allocated from: #0 in malloc #1 in __vasprintf_internal #2 in vasprintf #3 in g_vasprintf #4 in g_strdup_vprintf #5 in g_strdup_printf #6 in object_get_canonical_path ../qom/object.c:2096:19 #7 in blk_get_attached_dev_id_or_path ../block/block-backend.c:1033:12 #8 in blk_get_attached_dev_path ../block/block-backend.c:1047:12 #9 in send_qmp_error_event ../block/block-backend.c:2140:36 #10 in blk_error_action ../block/block-backend.c:2172:9 #11 in ide_handle_rw_error ../hw/ide/core.c:875:5 #12 in ide_dma_cb ../hw/ide/core.c:894:13 #13 in dma_complete ../system/dma-helpers.c:107:9 #14 in dma_blk_cb ../system/dma-helpers.c:129:9 #15 in blk_aio_complete ../block/block-backend.c:1552:9 #16 in blk_aio_write_entry ../block/block-backend.c:1619:5 #17 in coroutine_trampoline ../util/coroutine-ucontext.c:175:9 Plug the leak by freeing the device path string. Signed-off-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20241111145214.8261-1-farosas@suse.de> [PMD: Use g_autofree] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/block-backend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 7b329ff194..6128012953 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2138,10 +2138,10 @@ static void send_qmp_error_event(BlockBackend *blk, { IoOperationType optype; BlockDriverState *bs =3D blk_bs(blk); + g_autofree char *path =3D blk_get_attached_dev_path(blk); =20 optype =3D is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE; - qapi_event_send_block_io_error(blk_name(blk), - blk_get_attached_dev_path(blk), + qapi_event_send_block_io_error(blk_name(blk), path, bs ? bdrv_get_node_name(bs) : NULL, opt= ype, action, blk_iostatus_is_enabled(blk), error =3D=3D ENOSPC, strerror(error)); --=20 2.45.2