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: 1964041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Fzo+aERd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WT8Gg5tKsz1yZw for ; Wed, 24 Jul 2024 06:42:35 +1000 (AEST) 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-Google-Smtp-Source: AGHT+IHnk625/khGNvD1ccVYa/EYeq0wZHtqPBlRu5r5aTdSfBJWafRkUQ1h+3UZLC4HuSFHRGpYYg== 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.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);