From patchwork Tue Jul 23 20:38:45 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: 813984 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2489661wro; Tue, 23 Jul 2024 13:42:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUXE3/SxJXzLsRyMDfE6qWnX8PxllEqWax1n/GAD4jtVFUXAGy9q4Gqa2nWLC3sMARtyml9dV1lvls0xMzgNkPP X-Google-Smtp-Source: AGHT+IGyaqsOP/2PvEmi4mrmcff/saDI0FJ31RfTq2a60SihwtKkyAC2umoA2L1+VdqMSDt4XBEr X-Received: by 2002:a05:620a:2441:b0:7a1:9a00:9aaf with SMTP id af79cd13be357-7a1cbd26293mr17660785a.55.1721767354767; Tue, 23 Jul 2024 13:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721767354; cv=none; d=google.com; s=arc-20160816; b=0rCRsgXwAjEuEmRZAAvZuJFFHsp0CHA/lctX8NSUPvrPTGhR+VDW5eI5t+H4869wW0 gp1SjH9GaxJhi+25GanNOpZWmYcccHeBtOBcNWHSiGW7QoLAAxohBjggQJS1wuWzKod8 Fk8EN2RpW66j2Q4OuEfV4b2RwyZEM59krs3fsXZQcwfFiztzEEiw3x+is5bTMAnnem0u owe8JoMu+9ADj0oQljgP0VhI+uoO/rOsMVTg1zvHHcfm4xAfMH57qN4f/NAa4KYMwrTn Du3ID5i+Wip2g20OLfu6TaIJBXAsFs3jaA0VVlUM55juQqCNkUNswA5aPcC+Z3A/65lN shPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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=McKHquff5/qMRalcyN7OIwCMwCYYM5fhTICEYe9ToHg=; fh=+95r5kQR6IukR7ZYhJTgQlrK+EjvhO3YVAakLK9B5LI=; b=b80ZNpwp3Rin1VdMK4Y5jQlUMGFeLAtsBk4eDqiKIl2zJX3b5v7ctBC+uZpCst4SzX RIkYGxuUG7PumDxfKi04VwK5wHc3v9fPJFJ1V8gkA4C1uFbBhYJFvkCrrt+8Kmdt/P0e Jl0EkDT57KjPzOd0CqB3xHk/xUsMe8/gYDMQCA6XWVFjKso3AzDXwXgskrxOghEhnNqS zu8HIcy0l80me0rDZEApUJLuaeolD1xnH9kJTS+frRscwCoT11rJTtVzt4sYcVrmh7wQ 0Cqs2ymHD7UjthVcg5beTUV05EEHSnI5qSHoxfIuSpNQTv9RBKJgMyz6KT1oUmpci/hX 3ARg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fzo+aERd; 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 d75a77b69052e-44f9cdb9f3bsi109331701cf.363.2024.07.23.13.42.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jul 2024 13:42:34 -0700 (PDT) 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=Fzo+aERd; 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 1sWMJY-0002Wn-Gz; Tue, 23 Jul 2024 16:40:52 -0400 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 1sWMJP-0001ey-2H for qemu-devel@nongnu.org; Tue, 23 Jul 2024 16:40:45 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWMJN-0004QX-9B for qemu-devel@nongnu.org; Tue, 23 Jul 2024 16:40:42 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-36844375001so3393229f8f.0 for ; Tue, 23 Jul 2024 13:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721767239; x=1722372039; 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=McKHquff5/qMRalcyN7OIwCMwCYYM5fhTICEYe9ToHg=; b=Fzo+aERdpm7HcFj4Gd29zqVgcoYkCwGoOBa+Q0iGmgoC8mqWseAgeTaZU5NTdZg30o WPIIs7dXC39vFCKnJXoTcSoXaRdv2kuwnBzTzgw2swyUyKb55eIz1xN26na3VvPCIArV U56um/1BB76CISpzNuIRR+n5fYGacV1fAYxXDFDMCxul+2MF52cbm4l6Ytd2Trcn2ccS TYtKJUZPiKdI2tAQdzeeE5Q6n3E66dkUhhvldGPfNxs2+EVg1a/o9cKSrzu92f3bLZ5w V4v7rvvsg5jk5ub0r5mPJeIzR0kPX1ODOkcAF2dLgywd2hv+u8n9KPQt9eYu4kCPaYwN 2jzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721767239; x=1722372039; 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=McKHquff5/qMRalcyN7OIwCMwCYYM5fhTICEYe9ToHg=; b=vXehf20EcY3ejoV0Ei4GMMBfSKXF4AGLF/BHRFHMdOGPSzhZdRZmr3y39bs3lIwDGj Zk073w9VHDSjBdwKM8Zy3fNkz4B1tgv/S67z+roRBpewrR7jOtaaZh764bVBbWjh16Fu oxhVMqY5TXY/S8JrdvtiXT2Llm0CKfnFmKxGFykXwBJWlkBLkMinLYpUehbUOZDJqPEu L+vBqH+crm2BDQPHHr+JZHZexOVVQODQSmnopSmLz0I1R9Py6fYwSND93g0pmR8CZIVV sFuSKU1YJurTXEXt9NvGqpZanl6Gc1CFzfo/Vm6ZbzEy/2sZ6NgbuYW/GFiF7x6b4xZI QQwA== X-Gm-Message-State: AOJu0YwwcEiaHKq9TVeD+nmKo4nCfAolbbuiwyh2MgL2Ogztx/pSW+e3 FEq5NsxguG87AcIkPa+dMVr9QdmvkXhryAOtbt3sTyMAosS3h1+K3evjFroYXbmGZbhMohBneCJ vypE= X-Received: by 2002:adf:9790:0:b0:367:909b:8281 with SMTP id ffacd0b85a97d-369f5b9ebdcmr19251f8f.59.1721767239488; Tue, 23 Jul 2024 13:40:39 -0700 (PDT) Received: from localhost.localdomain (vbo91-h01-176-184-50-4.dsl.sta.abo.bbox.fr. [176.184.50.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3687868482esm12386768f8f.16.2024.07.23.13.40.38 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Jul 2024 13:40:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Zhao Liu , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 18/28] hw/nubus/virtio-mmio: Fix missing ERRP_GUARD() in realize handler Date: Tue, 23 Jul 2024 22:38:45 +0200 Message-ID: <20240723203855.65033-19-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240723203855.65033-1-philmd@linaro.org> References: <20240723203855.65033-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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: Zhao Liu According to the comment in qapi/error.h, dereferencing @errp requires ERRP_GUARD(): * = Why, when and how to use ERRP_GUARD() = * * Without ERRP_GUARD(), use of the @errp parameter is restricted: * - It must not be dereferenced, because it may be null. ... * ERRP_GUARD() lifts these restrictions. * * To use ERRP_GUARD(), add it right at the beginning of the function. * @errp can then be used without worrying about the argument being * NULL or &error_fatal. * * Using it when it's not needed is safe, but please avoid cluttering * the source with useless code. In nubus_virtio_mmio_realize(), @errp is dereferenced without ERRP_GUARD(). Although nubus_virtio_mmio_realize() - as a DeviceClass.realize() method - is never passed a null @errp argument, it should follow the rules on @errp usage. Add the ERRP_GUARD() there. Reviewed-by: Markus Armbruster Signed-off-by: Zhao Liu Message-ID: <20240723161802.1377985-1-zhao1.liu@intel.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/nubus/nubus-virtio-mmio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/nubus/nubus-virtio-mmio.c b/hw/nubus/nubus-virtio-mmio.c index 58a63c84d0b..7a98731c451 100644 --- a/hw/nubus/nubus-virtio-mmio.c +++ b/hw/nubus/nubus-virtio-mmio.c @@ -7,6 +7,7 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "hw/nubus/nubus-virtio-mmio.h" @@ -23,6 +24,7 @@ static void nubus_virtio_mmio_set_input_irq(void *opaque, int n, int level) static void nubus_virtio_mmio_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); NubusVirtioMMIODeviceClass *nvmdc = NUBUS_VIRTIO_MMIO_GET_CLASS(dev); NubusVirtioMMIO *s = NUBUS_VIRTIO_MMIO(dev); NubusDevice *nd = NUBUS_DEVICE(dev);