From patchwork Mon Nov 11 17:03:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 842468 Delivered-To: patch@linaro.org Received: by 2002:a5d:6307:0:b0:381:e71e:8f7b with SMTP id i7csp3145332wru; Mon, 11 Nov 2024 09:04:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXDKEHynP6rvzHFgglg3mUIGaxUUnruATIpRdpeVd56W7VlShDfetzIC+Wlhm4XSU+rGFtpEQ==@linaro.org X-Google-Smtp-Source: AGHT+IHrpWcz8YTV2XleiI0YqvBxVcMD6w7eBKaoegVn67jOpMnTuat0DlcaRW2i5IYAnI1Vj2wk X-Received: by 2002:a05:620a:404a:b0:7b1:3b99:de14 with SMTP id af79cd13be357-7b331f2f0b1mr2001651085a.57.1731344681875; Mon, 11 Nov 2024 09:04:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731344681; cv=none; d=google.com; s=arc-20240605; b=hl0+y+PxgpYP8rJIh9JECPA8cZxLF356OS/ug3+5ZVIEntJBvXVE/qLdsOAiAQp6Eq RVPX5z8GcaGmy51VdKQ8eyb0SbCLtdeQZqylweyFdKSUUTHX7k5mT+MxCzyn8vzJfS2Y PMV2AbwswLcQepxWzA3+msaILY5u2HZWOAT323uClUTj4bEzLwmscbfnX6h40Zq+ZNre OuF3ot/9FQSzrbJP/cxe8VLW90vp3wHA1a9byaqmUk6FIUMQzMukX9AeO5QZxIszs6bH ElqBGeoNZdmB3qO0rCAuHEhARqPFCGTaBVdGxcKj0c7pF6S34V3uTIpc5+QfpP6694PH 3lFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4PxJcypGLJUZeCvO6UFQ988vSD/DmSC0a3FHBYB21+M=; fh=A/+SSVK6Tgn9/+VO+jwbY7fYZvaiyFDUuLlyUta2+dI=; b=A5FRzNiXtTTfbkjab1fPqPCCNjLfIdRlrFVMRkfVyKaPlFi1KRubegQL2A5yn6/1XK cddYOftsbhMHkK4OipBi5wwt0oyt9Y9aC4nTldI54vRtnkOvfAauoCQSbBas8lbgtFXV qTp14rJ2P0wt+Okgr85RexDTSJUBIiazhuNjJ3wP55SrFr4dtce5CHSOLxYTJmjaqw8o Dw4XWaNAcZpZUD7dOTcAA0+wWKGzY0k/ASblbWm7Umoem8S+MzuM6evDJLzpn1pd5Vsy ASZA8qgayrncicCs6xe4UZVVLCrB3AHR9Bw5ZxC2uXaDlmV8chmJT3y2p8UiKjt/ifoW B4ZQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sM1URRbR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b32ac3d7a6si1198219785a.43.2024.11.11.09.04.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Nov 2024 09:04:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sM1URRbR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tAXpP-0005uG-VS; Mon, 11 Nov 2024 12:03:52 -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 1tAXpK-0005tP-90 for qemu-devel@nongnu.org; Mon, 11 Nov 2024 12:03:46 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tAXpI-0007hY-MG for qemu-devel@nongnu.org; Mon, 11 Nov 2024 12:03:46 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4314b316495so38710755e9.2 for ; Mon, 11 Nov 2024 09:03:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1731344623; x=1731949423; 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=4PxJcypGLJUZeCvO6UFQ988vSD/DmSC0a3FHBYB21+M=; b=sM1URRbRB/Y1aL5DoNXuey9khq+if4TKZFpkaGh2StF7JL4u1FcQFxTQaJ5HPDNovg +GJNxbmu6cKTGsntGhq3DFVoJcnqNh6BbOnYaE1nxeBm1oxo1C8V5of0oxL38QxC1tRZ LcfCG6i2yPm6AtDHfZsNCJTQ8fgR8ZZyPtT+3aUPczLVz5CoFA8lTFQ8if/uPiuqpm5h k+jkPs+iqhWG/yixioJiTzjuYoi4LmdjKgOr6W0EkzAr/q3m+vp5XKfizJSkwdJZgW6r GRZBBhZySx/BtGoXDLbI9+geSPyL9GG7kCA2k5PcPBYTpyZfcljn1SwL7P57G0z0fuXx fjaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731344623; x=1731949423; 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=4PxJcypGLJUZeCvO6UFQ988vSD/DmSC0a3FHBYB21+M=; b=CzrcbzkK1VPn1A5qB03SnQB/MooRoC+4F/oZ60FABhy5JmybiQwKODfg+W9qDArk07 Hs7dKv2lySaxAMdh3TMPAvv0AooGF23eziYXdJ8E1BFRxRC/986e6sMSu0QQVYZ/SokL RZ3ePF2OV1UDm+9QJM0QcyhkaDKeUCRYzgFM4aW16iK9MOhI9xFs2/x0tT3G+HAFPkRT ovSAbfIbYd94G5inwQTYGmx/MHqMFniPivh3/jQIBJMx+RTnRWIoX/n4tUP5DrLh8DYl NF8YREJlRHiiI0GgisEwcWS8z1TJULlZxtUh0xJ7KNY27eXehGRwCrfA9y+XJuMeP0aH CBiw== X-Forwarded-Encrypted: i=1; AJvYcCVXfanUVLnFJojMAsXbXDsICHZjQSyFLBnNxmsk5zrEdC/zOFS5ozbEkAzTAna39rz8dYLUgaZgauY7@nongnu.org X-Gm-Message-State: AOJu0YzQYwa0zJrBm9sq1UXO0+duKcYMccAWUwdU57Xs/WA80Yi+h3vu FJDJ+5xdxGYFmXqZf+bYLCeeHSUX/wLyttuhuO1Fq0hBASuKLOnY8mBBK68Tqwc= X-Received: by 2002:a05:600c:4590:b0:430:57f2:bae5 with SMTP id 5b1f17b1804b1-432b751cc3emr105100205e9.27.1731344623042; Mon, 11 Nov 2024 09:03:43 -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 5b1f17b1804b1-432b05c18e0sm184802655e9.28.2024.11.11.09.03.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 11 Nov 2024 09:03:41 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Fabiano Rosas , qemu-devel@nongnu.org Cc: Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/2] block: Improve blk_get_attached_dev_id() docstring Date: Mon, 11 Nov 2024 18:03:32 +0100 Message-ID: <20241111170333.43833-2-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 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Expose the method docstring in the header, and mention returned value must be free'd by caller. Reported-by: Fabiano Rosas Signed-off-by: Philippe Mathieu-Daudé --- include/sysemu/block-backend-io.h | 7 +++++++ block/block-backend.c | 12 ++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backend-io.h index d174275a5c..ba8dfcc7d0 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -32,6 +32,13 @@ void blk_set_allow_aio_context_change(BlockBackend *blk, bool allow); void blk_set_disable_request_queuing(BlockBackend *blk, bool disable); bool blk_iostatus_is_enabled(const BlockBackend *blk); +/* + * Return the qdev ID, or if no ID is assigned the QOM path, + * of the block device attached to the BlockBackend. + * + * The caller is responsible for releasing the value returned + * with g_free() after use. + */ char *blk_get_attached_dev_id(BlockBackend *blk); BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset, diff --git a/block/block-backend.c b/block/block-backend.c index 85bcdedcef..7b329ff194 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1019,6 +1019,10 @@ DeviceState *blk_get_attached_dev(BlockBackend *blk) return blk->dev; } +/* + * The caller is responsible for releasing the value returned + * with g_free() after use. + */ static char *blk_get_attached_dev_id_or_path(BlockBackend *blk, bool want_id) { DeviceState *dev = blk->dev; @@ -1033,15 +1037,15 @@ static char *blk_get_attached_dev_id_or_path(BlockBackend *blk, bool want_id) return object_get_canonical_path(OBJECT(dev)) ?: g_strdup(""); } -/* - * Return the qdev ID, or if no ID is assigned the QOM path, of the block - * device attached to the BlockBackend. - */ char *blk_get_attached_dev_id(BlockBackend *blk) { return blk_get_attached_dev_id_or_path(blk, true); } +/* + * The caller is responsible for releasing the value returned + * with g_free() after use. + */ static char *blk_get_attached_dev_path(BlockBackend *blk) { return blk_get_attached_dev_id_or_path(blk, false); From patchwork Mon Nov 11 17:03:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 842470 Delivered-To: patch@linaro.org Received: by 2002:a5d:6307:0:b0:381:e71e:8f7b with SMTP id i7csp3145422wru; Mon, 11 Nov 2024 09:04:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXdkZ0LsMHDjshVlT2qmRlwFj8o4sVl8ofID9A6mvYxg1wFFKPpXcYx0IYm54wauAgX8dgftQ==@linaro.org X-Google-Smtp-Source: AGHT+IECpH2qTUKbavwfN122a596jXwDQY8sTH2X/w12Ghy92+/b8FrV+m3envdDGKv+BbUn7vXT X-Received: by 2002:a05:6102:290d:b0:4a4:7928:637a with SMTP id ada2fe7eead31-4aae13500e7mr12138294137.3.1731344688218; Mon, 11 Nov 2024 09:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731344688; cv=none; d=google.com; s=arc-20240605; b=SxrfZ8QUXhm4xOYT5TcXpf8hi+zYOPl3DaqqBoSQA6A8Efre7s3p5FeUq78mQ/ufY3 2J3dM0F59Fj7K6V1JxWKmcuKZ3xhuCklkdQegUUjcRZfAyOvaA65p1dr8nqahTrwz8BI sIn3wmtw5i11sa7V5WYGQ/TVr8EfgFYxzWBjPLXOf1nq6uHt3a1QfDi6QGwdssAPdbTx LgNNg4y7yygYD3nEerDwnNgIfoBO3aFkAqrgAWZHPau+ASXHYXh8I+5hUukyF13VPqrY zsR1/iKQL5EhbXm4nvnhixBbg7bKhLFPdKhbnfhF+eW9z1pjt+rJT+7bAyVB2PZN5iwW QTag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aswoOKXvIzBRThw5Im2BrT+a+DMSnACXRZbpsdUuO5Y=; fh=9hbEH6tnZZQa7qhSPiy1BM7MEeOHZheqZCyrAlTyPKA=; b=HJedKsNoSZxIU2B1Dm7vHPjoBaWrVuRZxHpvnUCPvAiTdoAm5URp6e1aE4lnYPwjEB u2iN4oN4t0TGe/0JcfUL0hsbOtTzs/iqcuEMCL3z2IehTolFWEJXUqOZJOfON7xFzyTs n9u8LKJCS2hXq1sBLG+o3gqqLAB7qJF+O7CahXSrOyx0IWeGtTS4pmeqRWY//6FtvkyB LomAVf5IetrNsS1wMC2eV068N0TEkuIv6TXJ6KY1CyAEoz2O24imWeCQX9DwHh5fm0k2 M06j8VRwwawzvjgaPoAsmJFuxVHInoH0mDnz67BOA0zncdTfOPMvEuScWV2asqA3hz5y nVtA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cg4eMBiv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4aa97d32f8asi3054096137.13.2024.11.11.09.04.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Nov 2024 09:04:48 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cg4eMBiv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org 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) 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-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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Fabiano Rosas , qemu-devel@nongnu.org Cc: Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Message-ID: <20241111145214.8261-1-farosas@suse.de> [PMD: Use g_autofree] Signed-off-by: Philippe Mathieu-Daudé --- 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 = blk_bs(blk); + g_autofree char *path = blk_get_attached_dev_path(blk); optype = 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, optype, action, blk_iostatus_is_enabled(blk), error == ENOSPC, strerror(error));