From patchwork Fri Oct 4 07:37:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Cl=C3=A9ment_Leger?= X-Patchwork-Id: 11173681 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B258112B for ; Fri, 4 Oct 2019 07:38:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01C8520862 for ; Fri, 4 Oct 2019 07:38:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kalray.eu header.i=@kalray.eu header.b="PuCs27ON" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730633AbfJDHiQ (ORCPT ); Fri, 4 Oct 2019 03:38:16 -0400 Received: from zimbra2.kalray.eu ([92.103.151.219]:48294 "EHLO zimbra2.kalray.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730636AbfJDHiN (ORCPT ); Fri, 4 Oct 2019 03:38:13 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id DDA4A27E0F36; Fri, 4 Oct 2019 09:38:10 +0200 (CEST) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id rl8GD9ew8mil; Fri, 4 Oct 2019 09:38:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 6454827E0E5F; Fri, 4 Oct 2019 09:38:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu 6454827E0E5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1570174690; bh=m0IZGO1OMSmC0Bn/Pt54UKIFEBspEgEXw7Mo4uN0eac=; h=From:To:Date:Message-Id; b=PuCs27ONIu4SzkrjDdamr5UXsC416N7uxh+ro8SjzcPwY8Q0E35FroLBlNGfa24Y2 40hvcTd26Lu55u0dKJQQyDsrR5MjQDhdkYtkamfBjist8R+I+46RV+KSGg2gaI/mXz rCnUDqS5IBOZ3frv3wW6O7ReWPhV349FlOLH0FOE= X-Virus-Scanned: amavisd-new at zimbra2.kalray.eu Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id f-YyJ9MZVqKT; Fri, 4 Oct 2019 09:38:10 +0200 (CEST) Received: from triton.lin.mbt.kalray.eu (unknown [192.168.37.25]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id 504D327E0E2E; Fri, 4 Oct 2019 09:38:10 +0200 (CEST) From: Clement Leger To: Ohad Ben-Cohen , Bjorn Andersson , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Clement Leger Subject: [PATCH] remoteproc: Fix wrong rvring index computation Date: Fri, 4 Oct 2019 09:37:36 +0200 Message-Id: <20191004073736.8327-1-cleger@kalray.eu> X-Mailer: git-send-email 2.15.0.276.g89ea799 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Index of rvring is computed using pointer arithmetic. However, since rvring->rvdev->vring is the base of the vring array, computation of rvring idx should be reversed. It previously lead to writing at negative indices in the resource table. Signed-off-by: Clement Leger --- drivers/remoteproc/remoteproc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 3c5fbbbfb0f1..ab7443874635 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -400,7 +400,7 @@ rproc_parse_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i) void rproc_free_vring(struct rproc_vring *rvring) { struct rproc *rproc = rvring->rvdev->rproc; - int idx = rvring->rvdev->vring - rvring; + int idx = rvring - rvring->rvdev->vring; struct fw_rsc_vdev *rsc; idr_remove(&rproc->notifyids, rvring->notifyid);