From nobody Sun Apr 28 12:55:41 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652721704; cv=none; d=zohomail.com; s=zohoarc; b=BhCQtPCb4oMt6o8cGQwVsMPU6tCY3t4d+6NfvvBKMxWFEw42V5q8CdUSOoXtMkIBWjwnmtMY/A1DRem05ddxgyaBPaeoveJXVsmfO7RMm/POnpMrBpU1LYlVv3JG2cxS/sDiFTdIRLYiG85fovm/gnYDF+9aOnqgd7rzFn0K+Lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652721704; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=VPFd4/3+j0n5eO2jGcw7CH3r3KNkiZeErwPHNYtRMfc=; b=fOMsBIb+/qx2il2C9NO4eIAiZkJNIkcWLhnQ5UFCOF8InYDgGHczdJqmSTFLPibho36x72COFpIecTf2wdZrR5en2xNzyKtFJbhAyNmQtA4V8Cq87CvprLgOGULFOt8g1FF2Xh++4oYTzmVH42r5QaTx69+UG1GUVH6JFovYmHU= 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 1652721704835491.38067856839837; Mon, 16 May 2022 10:21:44 -0700 (PDT) Received: from localhost ([::1]:58720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqePf-00058s-RJ for importer@patchew.org; Mon, 16 May 2022 13:21:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqd5p-0003Ih-4P for qemu-devel@nongnu.org; Mon, 16 May 2022 11:57:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32239) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqd5n-0003TO-IL for qemu-devel@nongnu.org; Mon, 16 May 2022 11:57:08 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-255-MZMLfXzXNGylTA0t-eRAOQ-1; Mon, 16 May 2022 11:57:03 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2DE243831C59; Mon, 16 May 2022 15:57:03 +0000 (UTC) Received: from localhost (unknown [10.39.192.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3837C15E71; Mon, 16 May 2022 15:57:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652716626; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=VPFd4/3+j0n5eO2jGcw7CH3r3KNkiZeErwPHNYtRMfc=; b=PmDm7lt30+8NhF4DC0BBFP3aCez50ihMmLmdHBUUiBfLY5E4RErvOlV+Bg83OZTIp9DAKN 8VnjIeeGArJCd/LQbeyTRU8oNW1oWdLT2eUE4StrPgRGhgpVwWg87kl7eDsdIG2QDHW8PF RvOlf0mtCjQeu4H4pP82sb3tBakQmqE= X-MC-Unique: MZMLfXzXNGylTA0t-eRAOQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Peter Maydell , Raphael Norwitz , "Michael S. Tsirkin" , Stefan Hajnoczi Subject: [PATCH v2] vhost-user-scsi: avoid unlink(NULL) with fd passing Date: Mon, 16 May 2022 16:57:01 +0100 Message-Id: <20220516155701.1789638-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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=170.10.129.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652721706645100001 Content-Type: text/plain; charset="utf-8" Commit 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("Implements Backend Program conventions for vhost-user-scsi") introduced fd-passing support as part of implementing the vhost-user backend program conventions. When fd passing is used the UNIX domain socket path is NULL and we must not call unlink(2). The unlink(2) call is necessary when the listen socket, lsock, was created successfully since that means the UNIX domain socket is visible in the file system. Fixes: Coverity CID 1488353 Fixes: 747421e949fc1eb3ba66b5fcccdb7ba051918241 ("Implements Backend Progra= m conventions for vhost-user-scsi") Signed-off-by: Stefan Hajnoczi Reviewed-by: Peter Maydell Reviewed-by: Raphael Norwitz --- contrib/vhost-user-scsi/vhost-user-scsi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user= -scsi/vhost-user-scsi.c index b2c0f98253..9ef61cf5a7 100644 --- a/contrib/vhost-user-scsi/vhost-user-scsi.c +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c @@ -433,13 +433,16 @@ out: if (vdev_scsi) { g_main_loop_unref(vdev_scsi->loop); g_free(vdev_scsi); - unlink(opt_socket_path); } if (csock >=3D 0) { close(csock); } if (lsock >=3D 0) { close(lsock); + + if (opt_socket_path) { + unlink(opt_socket_path); + } } g_free(opt_socket_path); g_free(iscsi_uri); --=20 2.36.1