Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2822726pxb; Thu, 3 Feb 2022 15:35:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTovT/FXZ8TqwHSvGNZv7OhBPB9c5enemVrX961eglSupw/tU2QVexR4/2woHVG0QDEB6D X-Received: by 2002:a63:4182:: with SMTP id o124mr319846pga.479.1643931310955; Thu, 03 Feb 2022 15:35:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643931310; cv=none; d=google.com; s=arc-20160816; b=sRPWthxLrNldj4BDDAO3j7qwzzk7+2ZzsIYqCI4g7KRUxHoY5ZgbCKCZASckXFjfcD lpt5bfAwfvgB4zsKpoGBBbF8ZFoEM+eudOz+XaR6p1sPjzoo9QZfwI++ycpzc3bMwT8U Qi9nd7qgD5gDWf/pxaldBPiTEZamZJ+fKSKnP6bzvjZhgJ7rGiRQH7VZbVfCx3+MP+S9 nGW2/mMWX5e5KFz4XCNtxwqkPvORtQ3Gdnx7baNtkepsk48qbV6sJ6dTv2yqVvLBfF2v 4rlHUIEgkk6rQFzPXktiHOIEG6ouuOgmiaNlQPUm6DuifiLBvkvmP/DEVD1GBY373IXF L5HA== 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=9e0oxCku0Awg8Sfq6RwVv/SH5AvdTEcLXDJ8KHAWSBI=; b=rj2kQ8WTDrQHYlBy/J/sdr8rQWuP0srGJlyk5QoScbGdowJn6gYaIf+e3QFoeTAot7 Robtt2sKt4Jl9MaogDCXloSxa7J9OynkyvNpfzqg97crVaakzi5piYSmVyNItXG6T0q3 RiAj9179+g6ngWp7Y2n8EcN3t0MvClRFo0JRHjfuTC1iBSKH5NM+IJGPNw8KtBLE/f0D p5NbJ56NWxJ8qJXZbtUXypEt3NDVJWKOOpP5gZTuJcg5xnUD4bvUCLctGiJnFwpyAGSf pHQmZKF8oR0abJeDdOz4ETjI/VCgktgdwrx4YNV0HdvDx5hwn18WEKMyv1TnT2LfP1ws 1RZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=taFBh+th; 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 q6si232832plh.410.2022.02.03.15.34.59; Thu, 03 Feb 2022 15:35:10 -0800 (PST) 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=taFBh+th; 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 S239186AbiBCRfT (ORCPT + 99 others); Thu, 3 Feb 2022 12:35:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243503AbiBCRfP (ORCPT ); Thu, 3 Feb 2022 12:35:15 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B13E9C061714 for ; Thu, 3 Feb 2022 09:35:15 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id l24-20020a17090aec1800b001b55738f633so6202681pjy.1 for ; Thu, 03 Feb 2022 09:35:15 -0800 (PST) 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=9e0oxCku0Awg8Sfq6RwVv/SH5AvdTEcLXDJ8KHAWSBI=; b=taFBh+thCKl5Jv/LEOX1LgoAt1cWwIlDf2gcDD57Hl8dOAegKbyMp4wwejfdITEY6n aRhE9cCKXTHjAjDxE2ms/2VVej2/Z3Nal7SC6V0aVlyjoQRfTYQkTWolE3o94pJppD33 4DIBpeM8/8m4dD9OyiuPIyS6tXloCSJrPvkvcbaffucKQ+ullmkKYeCdT8k5yzOM4Cef OU2QLpM8gynxD27x9GvTAXlQOaqufYtIfqGAKfaeZiBmPYYJuWLWjapuJ9f8ozDMgYE+ 5LjhCpz2B84WMwZ/W4+EcqCMDKr6kqpVgf3UUpvNfbrOKc9ncVSuX7Pds/rggeqYYwdW PQ3g== 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=9e0oxCku0Awg8Sfq6RwVv/SH5AvdTEcLXDJ8KHAWSBI=; b=cWHFtvqh+YbyJaPQhIbL9h64HIi+TZ73ExbVmfWFTy8Uv+/KrsAya8iPOaApicfWvn bYkyL40UHSCpb0NNdvnygw3XztumQnIdj3bFIaMpr4i1TTtJCBFNl6JG39tP086E7ksS 0azItEEeCnugum3jbANR0VG/Y8zCUJGUYWLLf/LU3p3GUZgmxNKTPtftd7B8RFFpA7Pa 8iIqdb+hH6fVtbsLUDDa43hRcfUh0G17O70h5JXw8f9E+XlgZKVZhhQupTOsC5qVfjit ZRChx2iItzGqW/FjNfA10LsLeQ4z6jz8Ex2kFb00cQmqixDQHt4V2/AUCb+uAOkZDYp1 jW9w== X-Gm-Message-State: AOAM531luGF3hT2mqukEw6nmHut2+lJyBL4X+0T2hS1ph3Vum+QKiLZQ 4Z9L7tvUde6VKz2B5HxnPONoLw== X-Received: by 2002:a17:903:22d1:: with SMTP id y17mr36826313plg.107.1643909715150; Thu, 03 Feb 2022 09:35:15 -0800 (PST) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id me4sm11085727pjb.26.2022.02.03.09.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 09:35:13 -0800 (PST) Date: Thu, 3 Feb 2022 10:35:10 -0700 From: Mathieu Poirier To: Deepak Kumar Singh Cc: bjorn.andersson@linaro.org, swboyd@chromium.org, quic_clew@quicinc.com, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, Ohad Ben-Cohen Subject: Re: [PATCH V1 1/3] rpmsg: glink: Free device context only when cdev not in use Message-ID: <20220203173510.GA2982815@p14s> References: <1643223886-28170-1-git-send-email-quic_deesin@quicinc.com> <1643223886-28170-2-git-send-email-quic_deesin@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1643223886-28170-2-git-send-email-quic_deesin@quicinc.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Deepak, On Thu, Jan 27, 2022 at 12:34:44AM +0530, Deepak Kumar Singh wrote: > Struct device holding cdev should not be freed unless cdev > is not in use. It is possible that user space has opened > char device while kernel has freed the associated struct > device context. > > Mark dev kobj as parent of cdev, so that chardev_add gets > an extra reference to dev. This ensures device context is not > freed until cdev is is not in uses. > --- > drivers/rpmsg/rpmsg_char.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c > index c03a118..72ee101 100644 > --- a/drivers/rpmsg/rpmsg_char.c > +++ b/drivers/rpmsg/rpmsg_char.c > @@ -417,6 +417,7 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev, > dev->id = ret; > dev_set_name(dev, "rpmsg%d", ret); > > + cdev_set_parent(&eptdev->cdev, &dev->kobj); > ret = cdev_add(&eptdev->cdev, dev->devt, 1); This issue should have been fixed when cdev_add() was replaced by cdev_device_add(), something you will find on v5.17-rc2. Also, this set is generating checkpatch warnings and as such I will not review the other patches in it. Thanks, Mathieu > if (ret) > goto free_ept_ida; > @@ -533,6 +534,7 @@ static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev) > dev->id = ret; > dev_set_name(&ctrldev->dev, "rpmsg_ctrl%d", ret); > > + cdev_set_parent(&ctrldev->cdev, &dev->kobj); > ret = cdev_add(&ctrldev->cdev, dev->devt, 1); > if (ret) > goto free_ctrl_ida; > -- > 2.7.4 >