From nobody Tue Oct 28 02:10:45 2025 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 1516114161301263.4341547597893; Tue, 16 Jan 2018 06:49:21 -0800 (PST) Received: from localhost ([::1]:39403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebSYC-00033r-DL for importer@patchew.org; Tue, 16 Jan 2018 09:49:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebS44-000328-ED for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:18:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebS43-0004hK-Fl for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:18:12 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:45368) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebS43-0004g8-9a for qemu-devel@nongnu.org; Tue, 16 Jan 2018 09:18:11 -0500 Received: by mail-wm0-x244.google.com with SMTP id i186so8657122wmi.4 for ; Tue, 16 Jan 2018 06:18:11 -0800 (PST) Received: from 640k.lan (dynamic-adsl-78-12-229-84.clienti.tiscali.it. [78.12.229.84]) by smtp.gmail.com with ESMTPSA id u10sm1537758wrg.6.2018.01.16.06.18.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 06:18:08 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=eP8gLKdjr9LJG1Q7q7ujTcqRzIXaqHbCyeQ33t1MCeE=; b=LYoQfIagIeAdciPEKRA4cShYqEacr0kLuTpVaMkw1TJ8qUuKOHvLEeqZiVzz53Effc EkW0gxDPrrxbmBRIoh/6iuRTCOQN7l0g8IJ1VYS6ioYbB2XWryjajaYUZ2o4SvNwg9Ij h5H2tm2ujBbWgX5hwf3MgG0jCLkDXA22YuDbiHiSXd8qfdJHMaZemlsrCUqeISUB6CZ8 fHkzPHZLXMXljzDjHmUGMa1jR+iGo09Le4jVkEh0SAQa4cvy8A4hs5DmX2RGgLdLA12C c6L8R+Rrk/bgymV8ok0nLOdSKfjSxrdI+BeQAkhOWqijJuaee2GgTB6++jUoTaMKyWbe yCzw== 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:mime-version:content-transfer-encoding; bh=eP8gLKdjr9LJG1Q7q7ujTcqRzIXaqHbCyeQ33t1MCeE=; b=GN2bs0nn7q16jR4nzau9VA8ySe7kW94eloCsXfIBqB9/cnM+djmRJamR8tbs8aO9IM eLr+ExwhGrhZ/Z5MIWPpCshVN5GL2t0F55zsQWeu1LVnl6PFe4iN4hQASZsyfhmyhAaS xF6oTN4DriCdMxurlnIT0YsABeF/5c4Ugi8H7VGeP2YiArpxgmYa9wX1pPtlFT4IWlaY 9UadEGy7Oqxwx3rkxmdy5D15sVLK+PumfX2Wu9vX/9A7bmoAKtoTMEiQk0HvFS04Wk+0 dNp8g9jYqDpHEPFn/AXRlijQqXNytFvn3nn+rTBIklYLYbr50XdKBKpRqrOVw+8otspk 2m3w== X-Gm-Message-State: AKwxytdCj1h6awpNZ11ras2jakhFA75lj7txdWYdWheOBR6fAJuuwPlX MYpeOJnmo1/y1rcF9tvLKx6oey8j X-Google-Smtp-Source: ACJfBov1odzacCDFYOcSkzaWnN04mxBuEon7dZ+r1tWWdwDC4NAH2vn4edHlpjV57Pzn14OamqcGGw== X-Received: by 10.28.148.150 with SMTP id w144mr13239485wmd.0.1516112289693; Tue, 16 Jan 2018 06:18:09 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 16 Jan 2018 15:17:05 +0100 Message-Id: <1516112253-14480-24-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516112253-14480-1-git-send-email-pbonzini@redhat.com> References: <1516112253-14480-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 23/51] mips: fix potential fopen(NULL,...) 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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 From: Marc-Andr=C3=A9 Lureau Spotted thanks to ASAN. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-Id: <20180104160523.22995-18-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- hw/nvram/ds1225y.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/nvram/ds1225y.c b/hw/nvram/ds1225y.c index 57d5ab2..ad7345f 100644 --- a/hw/nvram/ds1225y.c +++ b/hw/nvram/ds1225y.c @@ -80,7 +80,7 @@ static int nvram_post_load(void *opaque, int version_id) } =20 /* Write back nvram contents */ - s->file =3D fopen(s->filename, "wb"); + s->file =3D s->filename ? fopen(s->filename, "wb") : NULL; if (s->file) { /* Write back contents, as 'wb' mode cleaned the file */ if (fwrite(s->contents, s->chip_size, 1, s->file) !=3D 1) { @@ -126,7 +126,7 @@ static int nvram_sysbus_initfn(SysBusDevice *dev) sysbus_init_mmio(dev, &s->iomem); =20 /* Read current file */ - file =3D fopen(s->filename, "rb"); + file =3D s->filename ? fopen(s->filename, "rb") : NULL; if (file) { /* Read nvram contents */ if (fread(s->contents, s->chip_size, 1, file) !=3D 1) { --=20 1.8.3.1