Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp508297pxx; Wed, 28 Oct 2020 09:55:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbryXkfnkHNP67Bj0skGdIzK0qS6K6ENao7bpn7F17P+h/faD3LKXO1Tm/2oHP5T3Kpxi7 X-Received: by 2002:a17:906:12cf:: with SMTP id l15mr8932463ejb.540.1603904133732; Wed, 28 Oct 2020 09:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603904133; cv=none; d=google.com; s=arc-20160816; b=DT0gUrNyys1972Ui3tCfKNINJOMtTOcgFzjQG7xtKb6cNDnses2EA08cbEkcfJqanK wjfvS86m1rJTF/t5k7N42nvyZVeqX3rQR6UWmL4t+wiIg3bQiSIRF+fMlmfkIkDB7m/z jK+eHMnpPKkAFujt6qzsWd+jxRUkVudQBeoFe6WnYMgOTcvAIw81lqtypjjT2v69l/E/ QfyOYeG1b2qD77ObCh3SQaIPORzC9j2EIU3+YFYz3EMv3AHvJ2o8ZhBrZQpGoSghTAvZ gwuf2bPpKPenMLjoFmOIAXLdtkNzicncOqNxbqXxqh+bFM94u4RASKfcdCMrEv2usIn5 qeCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aFOENJjQCxd8UfLGvlUVhVWHkc9db2Y8tuAIDBFUPMk=; b=a3ahmoRwNkuMqqTWnY+MkEGgaUVyHi7Q96a03/q5yssOGLtFqvhxmJslV4oGcg+ugI a9rFbvd+NK0lB6rIjxazx3z8oqbZQXCVN7srepKBTHYs8hQ0gHrW3RmANlFYY8exdhDh 6ySNgt7MXdR3uxNjMr9uuaTtQEg3j5bpzRvwIncXQm/bs79M2NaFYh2WPxWAmOyHFyLm nu8VhpuChDGWMw5tLNinWXVL/TguRMPhdUTLnlFdT4OdwURySbgbkk9XRv1kKO3DM6hs S7LnnTN6bAwNu2RgOwEYa8Iif5BA0aVgx76RC08BwBiqDanV2YpFozwhYCu9Z2xhjqmj OLSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="go/8M1KC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h20si3592583eja.402.2020.10.28.09.55.11; Wed, 28 Oct 2020 09:55:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="go/8M1KC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1818962AbgJ0R0O (ORCPT + 99 others); Tue, 27 Oct 2020 13:26:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:53648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1775750AbgJ0OxM (ORCPT ); Tue, 27 Oct 2020 10:53:12 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB05820679; Tue, 27 Oct 2020 14:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810391; bh=8dY6wm1gJfitlu3ZFizi9O43Lh8fT2w4dmwJbNcIrUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=go/8M1KCJU+joCLuLPoNTP8SozrTTGYBnp3nMSyvm/jgp5WTSSUt03JEeJ30D1AaS ekm8yL8f75uAR6AyrTiRg64CFpdOpgpgjub2Uknp9cmZ+cowG2Yr5JBb3k+iP+a4W3 8BwxmqSft8WqnO6qM+ZmKqV6l4gM3HzDIQk/TXVs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurent Pinchart , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.8 123/633] media: rcar_drif: Allocate v4l2_async_subdev dynamically Date: Tue, 27 Oct 2020 14:47:46 +0100 Message-Id: <20201027135528.477223248@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laurent Pinchart [ Upstream commit 468e986dac0e94194334ca6d0abf3af8c250792e ] v4l2_async_notifier_add_subdev() requires the asd to be allocated dynamically, but the rcar-drif driver embeds it in the rcar_drif_graph_ep structure. This causes memory corruption when the notifier is destroyed at remove time with v4l2_async_notifier_cleanup(). Fix this issue by registering the asd with v4l2_async_notifier_add_fwnode_subdev(), which allocates it dynamically internally. Fixes: d079f94c9046 ("media: platform: Switch to v4l2_async_notifier_add_subdev") Signed-off-by: Laurent Pinchart Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/rcar_drif.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/rcar_drif.c b/drivers/media/platform/rcar_drif.c index 3f1e5cb8b1976..f318cd4b8086f 100644 --- a/drivers/media/platform/rcar_drif.c +++ b/drivers/media/platform/rcar_drif.c @@ -185,7 +185,6 @@ struct rcar_drif_frame_buf { /* OF graph endpoint's V4L2 async data */ struct rcar_drif_graph_ep { struct v4l2_subdev *subdev; /* Async matched subdev */ - struct v4l2_async_subdev asd; /* Async sub-device descriptor */ }; /* DMA buffer */ @@ -1109,12 +1108,6 @@ static int rcar_drif_notify_bound(struct v4l2_async_notifier *notifier, struct rcar_drif_sdr *sdr = container_of(notifier, struct rcar_drif_sdr, notifier); - if (sdr->ep.asd.match.fwnode != - of_fwnode_handle(subdev->dev->of_node)) { - rdrif_err(sdr, "subdev %s cannot bind\n", subdev->name); - return -EINVAL; - } - v4l2_set_subdev_hostdata(subdev, sdr); sdr->ep.subdev = subdev; rdrif_dbg(sdr, "bound asd %s\n", subdev->name); @@ -1218,7 +1211,7 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr) { struct v4l2_async_notifier *notifier = &sdr->notifier; struct fwnode_handle *fwnode, *ep; - int ret; + struct v4l2_async_subdev *asd; v4l2_async_notifier_init(notifier); @@ -1237,12 +1230,13 @@ static int rcar_drif_parse_subdevs(struct rcar_drif_sdr *sdr) return -EINVAL; } - sdr->ep.asd.match.fwnode = fwnode; - sdr->ep.asd.match_type = V4L2_ASYNC_MATCH_FWNODE; - ret = v4l2_async_notifier_add_subdev(notifier, &sdr->ep.asd); + asd = v4l2_async_notifier_add_fwnode_subdev(notifier, fwnode, + sizeof(*asd)); fwnode_handle_put(fwnode); + if (IS_ERR(asd)) + return PTR_ERR(asd); - return ret; + return 0; } /* Check if the given device is the primary bond */ -- 2.25.1