Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5507339ioo; Wed, 1 Jun 2022 07:02:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeQIyEL2yY2k3uQlNv24/rNZMCDWSj+L861h7A+WevDFM3Vih6w8JfTy2tLimuAL/JySoI X-Received: by 2002:a63:504:0:b0:3fc:607b:9750 with SMTP id 4-20020a630504000000b003fc607b9750mr107795pgf.604.1654092131912; Wed, 01 Jun 2022 07:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654092131; cv=none; d=google.com; s=arc-20160816; b=qbXeiTEtaQAO4erfBbAUD1yj0NpmN6+kEmS62AP7AaMWhpWmY2plRK79mx68iM+I+3 900ysCwKZRnWK9W3GJ6YdefdzKNVfP51zFSHQ/HkAvbyhlv/LK1vQq2vsbPALXhpFCGP 5SKDgnl8RIonU+PiyHQ4q05DaBfkrlRvGjahkEx6PWbAlaEyYlMNvWPIPzbx+OuYoiEv ayHtE3TbG9wLGtt8jksp9FKE8hlhCBEuG7b3gO7vxEzc/6wI6hZKbDC0Vz5Y9HcLpUY0 BIWmfpcYZAc5XrXzfir3BRZUx5VYKIY3LUWTJc2fL2z++EM3qkrdNjE5UfeEs1o8uks/ LDYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Tt/gOB9r37r5U7HxtgH6i80t5jbb5qgunubyztDkge0=; b=vvYdfhJQoK/Fc4yJEC3Mde8vLjfMyfRIeX8lOtNgkgdaj58ePAOkTBLvtbCgUFp2+9 zMTjEmgC6dyzJSZxg/1BkJfmWXOvxLW83i0WtM3TebmImLc/uJZKE+BQvJELLFwC0rWf tvcDrw+Jl7lJ+7ihPaUx8m729xxUtMtlgxZLFRo9/qEZ6a73vGR+ao0j85ciKLNxUpXR ZYKTNKrX8o9QsikheQmXL71vkYDdDt5NCgDebbJck52C9duv+NhaOKFGvtIQKpLoOTop Hfq4XSxqxDvvN3mSENRgEfBrKy8hfIvkAaPCllbJYq9f/PanXIbG2En+ec0q7DiMhRPm C1fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hkD/eBMG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd3-20020a17090b4cc300b001df5e0b50d9si2121676pjb.151.2022.06.01.07.01.49; Wed, 01 Jun 2022 07:02:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hkD/eBMG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346554AbiEaR2u (ORCPT + 99 others); Tue, 31 May 2022 13:28:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346551AbiEaR2s (ORCPT ); Tue, 31 May 2022 13:28:48 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D09F93989 for ; Tue, 31 May 2022 10:28:47 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id d129so13431458pgc.9 for ; Tue, 31 May 2022 10:28:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Tt/gOB9r37r5U7HxtgH6i80t5jbb5qgunubyztDkge0=; b=hkD/eBMGGcmdiFaBHu2BT3jb7UyDt9oVBtTZYhiizvoIp454sxeKhm8+MZKDbv5qFL ZK3rClkIYrmKjrTQ3GR3zWPw7A8PwXhkSr0llGzCp4uSt/YyXgQ2B2TfMu3F2r95GZic 973EYm5DKFtaHEQHWfolFJc9yzYxhgHyg0dY24KEKLkZCIKUdh6seNpGH7VmmX6CQ4Fn zcIpW97bdp2OTI8bY4n/SkBR+hg+Q+4o8aL4iD9m8GvM0HpFcA0xRNZ2Ix7tdb0cnl6i Aosu07MgtKInzCiGImh4PiFPYbCRXVWQcIWd1l/jCL+BseXymrtdp40b1nm/K3tux1+r X5fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Tt/gOB9r37r5U7HxtgH6i80t5jbb5qgunubyztDkge0=; b=NLM6HpWVYSGa1/lpi7jW3wIGVClXMpD8W8ZcJqRL/jmKd8NCxejW5eS4zr7Lo8ofVj 3Q1XnPEZ9LIH2hx+/gKgLA60BPEOMRv+VGaAg5rgIwGH4grTh/1ulyso9DiRb5ip9U+9 87iB+N7OCOeZAARraN0Ts1vf6RqsH2PmB92+lrziaXPdbun8rtBEXaaE+PncyG1U+TWI EBeKTY2yGezPD7BKdqK/U5XP7E8wtkL4XNJ98XajxUtLDyJqbbnGy7Aihm2kvAb4l5yL aUH7ERJUW0zBBhpoImF3l/ZbWZlxH4aAjXGu5Py1YXjbI3qU/bVL4G1KIQA1aTuqdC+9 ybkQ== X-Gm-Message-State: AOAM531/cIEQlk9T2Thl4CPqJAyTixZBPHBWz1uYwmmLfRhZlJZDXjeY X1XPgBeBqQS8+UmBbYPi24RdgW2eKCxj0w== X-Received: by 2002:a63:e5d:0:b0:3aa:3c53:537e with SMTP id 29-20020a630e5d000000b003aa3c53537emr53612711pgo.622.1654018126567; Tue, 31 May 2022 10:28:46 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id u21-20020a056a00099500b0050dc76281bcsm11202370pfg.150.2022.05.31.10.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 10:28:45 -0700 (PDT) Date: Tue, 31 May 2022 11:28:43 -0600 From: Mathieu Poirier To: Shengjiu Wang Cc: bjorn.andersson@linaro.org, arnaud.pouliquen@foss.st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, shengjiu.wang@gmail.com Subject: Re: [RESEND PATCH] rpmsg: char: Add mutex protection for rpmsg_eptdev_open() Message-ID: <20220531172843.GA531268@p14s> References: <1653104105-16779-1-git-send-email-shengjiu.wang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1653104105-16779-1-git-send-email-shengjiu.wang@nxp.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 21, 2022 at 11:35:05AM +0800, Shengjiu Wang wrote: > There is no mutex protection for rpmsg_eptdev_open(), > especially for eptdev->ept read and write operation. > It may cause issues when multiple instances call > rpmsg_eptdev_open() in parallel,the return state > may be success or EBUGY. > > Fixes: 964e8bedd5a1 ("rpmsg: char: Return an error if device already open") > Signed-off-by: Shengjiu Wang This looks good. I will fix the above typo and apply the patch when the 5.19 cycle starts. Thanks, Mathieu > --- > changes in resend: > - add fixes tag > > drivers/rpmsg/rpmsg_char.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c > index b6183d4f62a2..4f2189111494 100644 > --- a/drivers/rpmsg/rpmsg_char.c > +++ b/drivers/rpmsg/rpmsg_char.c > @@ -120,8 +120,11 @@ 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) > + mutex_lock(&eptdev->ept_lock); > + if (eptdev->ept) { > + mutex_unlock(&eptdev->ept_lock); > return -EBUSY; > + } > > get_device(dev); > > @@ -137,11 +140,13 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp) > if (!ept) { > dev_err(dev, "failed to open %s\n", eptdev->chinfo.name); > put_device(dev); > + mutex_unlock(&eptdev->ept_lock); > return -EINVAL; > } > > eptdev->ept = ept; > filp->private_data = eptdev; > + mutex_unlock(&eptdev->ept_lock); > > return 0; > } > -- > 2.17.1 >