Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp828697pxu; Wed, 6 Jan 2021 05:42:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzX9CwX0bffFtdVwXhQ3xu2vMSAymRTDWSzulnLOVvuwfyRhUxZh3zGXFxzegqOxmg22f1F X-Received: by 2002:a17:906:13da:: with SMTP id g26mr2806121ejc.285.1609940521046; Wed, 06 Jan 2021 05:42:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609940521; cv=none; d=google.com; s=arc-20160816; b=TRG6fKwBgMI/LuBtD+hGY3F3f8/W8CxIjSGa/ozlMpMvjDh81x5NJIgzjlRBiX0rMc aiW9IqqR+eiSYyBTn1mKvLq/BmFcKBPklfYnqkPvh6jNBB3rKfslOF8Bf+C+nr+advgI IacXr5X+u7g1x2UQ83YGHIpavhT0CuZTfhC1i3bkBvv3fElEtoaCJIVuUXp452+CNglz 69vKBYpI0G4JaY8tLTj/rsJL7xOxdD1OZHjI4EXgSyAHgXD81nnq6S7L4+iAAZ2470DE rruCiSKeH5BaAPRr+NRU5gAhZFgWKBPc7D8AQPXN1BraA3km6iRywVaHJBoZ3HV/qsfP w9Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=fFRoI9/vVcCXoEXjQQYHbpRW8fDaWqXof3RiPcHIjvY=; b=EdDN5PrXAXgno2+J0DtD9Epo/lZS4QOkuj39wj+1guKYDqlsd8qjV+VVOZroiCgKYK CW+frsduZgqgqzwy/33lhg/Iw2JZ6FHCe94EoT1sG2qCgcEsJvhuzah1cNugZkJ2ygSj ESivN/EdN8neMLQPtUYXYyhIjPAd43wBhWsVZSv6F3nJa3x/uYL5nPPxPPV1ZQxYP81S CsDu2CLqef5HqW1S1+myrJdp89rxyDcRU3ZR8sywuHhZlpp5ZkanOOtVC627g67l17Xb WqdoILr0MeDuQy/qNcsif+i25y/LB8+N6QBnnTy9C5CiIQzQJNdLLWYVw01iSNAoSM4a 9GpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=FCEKrG7m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n14si936997edq.574.2021.01.06.05.41.37; Wed, 06 Jan 2021 05:42:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=FCEKrG7m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727132AbhAFNi6 (ORCPT + 99 others); Wed, 6 Jan 2021 08:38:58 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:59537 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726993AbhAFNi5 (ORCPT ); Wed, 6 Jan 2021 08:38:57 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 106DbLiD014027; Wed, 6 Jan 2021 14:38:12 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=selector1; bh=fFRoI9/vVcCXoEXjQQYHbpRW8fDaWqXof3RiPcHIjvY=; b=FCEKrG7mdVGcfhr8yaOrtsUyQ2TK5+dKPllHIJW5Po6+XGEYx56Z1deOcPLCEZ1oeN7i Wei0y4HOZsbnwASDiMSiN4yXdXtFG2LUzPB5m23SVDFoabITaZKorFxKG3t36bxkKtL2 fQNpSQYK+bACybg8w4mfP2fb7d3+HaLygUmVyX3QMngqkNSzjao8loXKIHrq+0fK0OlP HcMtuGaM6tb8s6/HNqZ2J3Cj+6ImWO/yTKHpAYkdCdODoJbgaGWA67pmeCKBZNjc4QKS ZpxqE9S9Jf9gZb+PD2WrYp/MYGYpcMS4F+xRwTbs271RSp27u/p/AIZHzKWh7MPraoE4 Yw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 35tf6738cy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Jan 2021 14:38:12 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7F85D10002A; Wed, 6 Jan 2021 14:38:11 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 6C3D62AD2B0; Wed, 6 Jan 2021 14:38:11 +0100 (CET) Received: from localhost (10.75.127.45) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 6 Jan 2021 14:38:10 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [PATCH] rpmsg: char: return an error if device already open Date: Wed, 6 Jan 2021 14:37:14 +0100 Message-ID: <20210106133714.9984-1-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG3NODE3.st.com (10.75.127.9) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2021-01-06_06:2021-01-06,2021-01-06 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rpmsg_create_ept function is invoked when the device is opened. As only one endpoint must be created per device. It is not possible to open the same device twice. The fix consists in returning -EBUSY when device is already opened. Fixes: c0cdc19f84a4 ("rpmsg: Driver for user space endpoint interface") Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 4bbbacdbf3bb..360a1ab0a9c4 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -127,6 +127,9 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp) struct rpmsg_device *rpdev = eptdev->rpdev; struct device *dev = &eptdev->dev; + if (eptdev->ept) + return -EBUSY; + get_device(dev); ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo); -- 2.17.1