From patchwork Thu Aug 29 09:29:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 172547 Delivered-To: patch@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp2071985ocp; Thu, 29 Aug 2019 02:29:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRxjByKFCa6+gt21Elu5sevgnakA4cC9LYtWqcqB2As43UQYPsfqwfv9RZotOTXBF3iq9i X-Received: by 2002:a17:902:9a07:: with SMTP id v7mr8981470plp.245.1567070981428; Thu, 29 Aug 2019 02:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567070981; cv=none; d=google.com; s=arc-20160816; b=kaTeSjSBBby3TteMSphWA1nip1H+TBdR1fheDZLqA71WRYZ33Rtbdnubgxd46si13+ zGj0404wwbi6o69/5bJ1D60+inHE7ZZQR+fUbKUKkqRnKa6ekLOh1xD4UvUvWo23MC9C nmopv9IGtB/K2WEb2ORi5y3vXvtIP0LdN8spnNjodwU5k0PRzvx29R8CO+EBqf+WM54d lKfwhc3cyfpRCiJsfsCkWg0FWVXUuEUrma1Yr+eV8l8rU9GnCKpGY6crRrjdu1h46Osz zDxaujWXTbUYBcHkXd+DZH7oC88xtCSD5q1uf8anURQ1CD89XY2+pZRqmGpZHwAuxj+j Vmzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8gReQ7CjJRAhm4L6Tiz8Y9x8ZLQilV94lsV5veC3IIc=; b=JVHmRYRy7IOGubOGZ70ojbYRSaa7uoKO4FB2biZmi7K5UQwRTkN/vl+cDWGkSX0Fzo ZhUQTmBT0zGIcxfLVRHD/26FlhJkyrSFEJUCCH6L6eioF6qAhxOOT0VVdPooRurdIW+0 6/3YSpps3ED5EMmmx2YbI+AwXxDP6HnMp+jvTSad1Wc89efmCGXCgrz5ensZa9a3euUR rGbznl5fXnUR8Ni7ER8XfPJwTSlkee+L4vj4LlJ0qywl2P00ZQ10KPEcnz4oSeOgqgT3 rweaqJIweCW4eNbmIq8eMitsgUqFkWd2fwiwtNQwT7d1OBtHhna+CEtgJSeG8yk2EopQ bONQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PtDj5xCz; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m27si2016689pff.186.2019.08.29.02.29.41; Thu, 29 Aug 2019 02:29:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PtDj5xCz; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1727073AbfH2J3j (ORCPT + 16 others); Thu, 29 Aug 2019 05:29:39 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:52699 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbfH2J3i (ORCPT ); Thu, 29 Aug 2019 05:29:38 -0400 Received: by mail-wm1-f67.google.com with SMTP id t17so2945265wmi.2 for ; Thu, 29 Aug 2019 02:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8gReQ7CjJRAhm4L6Tiz8Y9x8ZLQilV94lsV5veC3IIc=; b=PtDj5xCzFk2wfuU6zYpS9GCEDFNAdkqEJTun597to8/wlUXA2ovkmt2++lgNbddgWj nghCcmSOy88teYBBZJklqSkpkrGk0u7G46HXOPF8zXasJG7NYAM4xbl+IrqiDHsa4a0t Us1d9idE5Oe+d+yY46bKYHNlylT6HBA1I4f9ZwezXwkD49LPzyQsGAN7eAW+RkSJIfrX oFM8uxkVTyFTRc9rtET54Bn2IAabx2x7VgSIL6F2u1KCjd6gCSJJ11GQ/KNwG/jIsSzh Zlf6IL+bUikvtRslDtQAgaYAJGHhijvgZ0U1TiJIxLjlZ0DTgAmlBZZXglO3NV/qtQoq 2AEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8gReQ7CjJRAhm4L6Tiz8Y9x8ZLQilV94lsV5veC3IIc=; b=QPSk37819q+fTxJjt4KDfOsQEJlA6wABnDn+ogvKTG867qxHS47K2Ik344mIOS4mpw 1lakuUgrXisxFXAyHQApuJyZHN3gWyaTj+lxvSJrRKxbg/dKyJNMMh7X1TsD0nbM3rO7 CvQMhW99wEffjzmmIm6EcpMJypR5UdGLFwja8/0A/AvRyNETihATkG8tPq/odd2hB485 8ZHThLK+7CIEinMQ5zaK/WhnS5ifSdX/95ngS/46Q+ltaQhnqQG+W21XeP79Rep3gj2h ODNTZfoLGdhjtrH+yuUkl0XRxPSb15bJ/+DBHvkxVNnA5q02A011xN84Sjzs+Cz+gvR8 n+5g== X-Gm-Message-State: APjAAAUjJZNGeV3eCgkZq2nZNX/sWJyGryAiemuxOSEJvNKpAfRSS1an hZxxPFpOpIPW4P7+NGetzLoqLQ== X-Received: by 2002:a7b:cc0f:: with SMTP id f15mr10002879wmh.39.1567070976668; Thu, 29 Aug 2019 02:29:36 -0700 (PDT) Received: from srini-hackbox.lan (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.gmail.com with ESMTPSA id f197sm3609512wme.22.2019.08.29.02.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 02:29:36 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: arnd@arndb.de, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Mayank Chopra , Abhinav Asati , Vamsi Singamsetty , Srinivas Kandagatla Subject: [PATCH v2 2/5] misc: fastrpc: Don't reference rpmsg_device after remove Date: Thu, 29 Aug 2019 10:29:23 +0100 Message-Id: <20190829092926.12037-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190829092926.12037-1-srinivas.kandagatla@linaro.org> References: <20190829092926.12037-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bjorn Andersson As fastrpc_rpmsg_remove() returns the rpdev of the channel context is no longer a valid object, so ensure to update the channel context to no longer reference the old object and guard in the invoke code path against dereferencing it. Signed-off-by: Bjorn Andersson Signed-off-by: Mayank Chopra Signed-off-by: Abhinav Asati Signed-off-by: Vamsi Singamsetty Signed-off-by: Srinivas Kandagatla --- drivers/misc/fastrpc.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.21.0 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index c019e867e7fa..59ee6de26229 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -913,6 +913,9 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, if (!fl->sctx) return -EINVAL; + if (!fl->cctx->rpdev) + return -EPIPE; + ctx = fastrpc_context_alloc(fl, kernel, sc, args); if (IS_ERR(ctx)) return PTR_ERR(ctx); @@ -1495,6 +1498,7 @@ static void fastrpc_rpmsg_remove(struct rpmsg_device *rpdev) misc_deregister(&cctx->miscdev); of_platform_depopulate(&rpdev->dev); + cctx->rpdev = NULL; fastrpc_channel_ctx_put(cctx); }