From patchwork Fri Aug 23 10:06:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 172105 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp428060ily; Fri, 23 Aug 2019 03:07:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGV231t3Ebjbo8BTqs5tZAf6ImQBeo7ASd45b4Q7Eo4Tkv5CI7FEWQJwPV1AS5oSZ1vFAP X-Received: by 2002:a63:b904:: with SMTP id z4mr3174922pge.388.1566554843586; Fri, 23 Aug 2019 03:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566554843; cv=none; d=google.com; s=arc-20160816; b=CfOx8g+lENGfhyl9MnRr0L4ByULMpbIUbOzrw/F1GetxZIJmpohGNG/K4dnowNKwhV OucS8th+tN4XCjkxy5/DLekJk7BPFZOb+nI14C3IwJOoDqtcAvxx5XLObF6LW3JRSOtk OBHg0kAaj3+H263xcGuYgkLLNqWNM8RoIO5KRGnm3LBiSjIYDqhfBXPAXvXhJNAle4sS Q+KUuMScvyL5+SdvjeyiW1QPZfON6bBnFaEP87zkheGlReSmrYP2up7KOjYN7YRZh9QZ wOQzIkwzgbB28TfUJiEE6TdU1kz46aqSTrendwVsFj258tE9U2Wn4Bg4PCVl/epg7+Tg CthA== 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=eaF1NgI3/tCvQBGNuV2Ozkr5swOUz9Q1YNoph3dPfCA=; b=zkaD0WdES8bu8rR15uIS/O4TYwPCjM+fNl/hC8U9N7BUCrx3CssJOegGH+T/6H1EUU worm4mkY7lNtMJw3p5/7MRxKx3zu2h6VCnzPOzanIUoitafaNL+f2meUEguJ7na1TLAv ia4tkQPFlygxeyGMmIg3E24JgTpMFrI5QTOSyCoYAN9tYcXUP9KqIioiFHwnleiBC2sx pxhb6PfxsBxtDPhb8LCVNhS63MZT5WNtnxgWbHahrOYHqdIc4ONuEuyywRFoOktH2r8Q LXVEPKMxc0u4o23H+/rNTG4NdCrmOwMSOoHHitXdpZBWvWN7FJT6RZ2fN1zk6ENFW5DQ /fCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=G1xW6LLi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t17si1552282pgv.54.2019.08.23.03.07.23; Fri, 23 Aug 2019 03:07:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=G1xW6LLi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2392175AbfHWKHW (ORCPT + 28 others); Fri, 23 Aug 2019 06:07:22 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:53353 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391917AbfHWKG7 (ORCPT ); Fri, 23 Aug 2019 06:06:59 -0400 Received: by mail-wm1-f65.google.com with SMTP id 10so8363000wmp.3 for ; Fri, 23 Aug 2019 03:06:58 -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=eaF1NgI3/tCvQBGNuV2Ozkr5swOUz9Q1YNoph3dPfCA=; b=G1xW6LLifBzrZM98pMoqJppw5kCp9ljlnOSzFRZtPclDF6fw8Cd2RUQbL0e+HEm3Vh XX47d4h6nOFaDu8xJVs81qT+pZ+mIy7lRkoybJ7YhLjSgksA+EHlJsTjucE5uYSVAZvo +maJ1dWGYioVbSCriunnxWS+VkjLwTXWXByvsLbX0bDs9OJaHQFzEhMuBh8ecp61O0fp jZVCvAk73YWOGRf70F/tbiI2HeEnsfYcO/0xZjti62IB6C9kIYLIC/r+QNPhKKbJ21zv TM0sAUn4q+jETQpBFdyuPj7eFjqls67JbdbpT3rW6taBVOyeCNlkgILM5x1fMUnJlyaO dEBQ== 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=eaF1NgI3/tCvQBGNuV2Ozkr5swOUz9Q1YNoph3dPfCA=; b=A5rkSuV61Epzf9c7YQ+W7zkk6gFFLqXxKvDGemSXKkrL+lM2GXhnmsgMlPBsqenf6c eeoO5VZKp4RgPqwNas67Qaljeim4/HcFEGydZ5qezD8BuGZxhpznjkM1In6lsQPojJrE cvu+F5S3pfHJ4+58+J4OQqDuYgnroaN2aoTywJBbZ846M084E28/3OZOSTinXEOfs3jX 43lKAib6Bct32so4L92GFJg1nEsriHSbRiIxhFj+8k6qVE5EFDMRLhMPgYzKtyYcT6Ex riHPi6FHHbWQ/6Cpg+HaaIlmx2qeHhlcqVKgSQ/8vlI0CVEwgMWJs8LJ4Un0Z/KVJwyv UXqQ== X-Gm-Message-State: APjAAAVDgN3/Cr0ADy1XCdcedZglBeEzqlpdbetX7SaNyc8J4obx4fJS 2+pFWTg82MnilGAxs9Lb6Pvd6A== X-Received: by 2002:a1c:2015:: with SMTP id g21mr4100755wmg.33.1566554817994; Fri, 23 Aug 2019 03:06:57 -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 q124sm2058048wma.33.2019.08.23.03.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2019 03:06:57 -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 2/5] misc: fastrpc: Don't reference rpmsg_device after remove Date: Fri, 23 Aug 2019 11:06:19 +0100 Message-Id: <20190823100622.3892-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190823100622.3892-1-srinivas.kandagatla@linaro.org> References: <20190823100622.3892-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. TEST=stop and start remote proc1 using sysfs 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); }