From: Alain Volmat <alain.volmat@foss.st.com>
To: sun yq <yqsun1997@gmail.com>
Cc: <mchehab@kernel.org>, <matthias.bgg@gmail.com>,
<angelogioacchino.delregno@collabora.com>,
<linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>, <499671216@qq.com>
Subject: Re: [PATCH] OOB read and write in mdp_prepare_buffer
Date: Wed, 28 Jun 2023 08:33:53 +0200 [thread overview]
Message-ID: <20230628063353.GA3625616@gnbcxd0016.gnb.st.com> (raw)
In-Reply-To: <CAA0BgY_Lj+hQdevrgK8y=wLztddnh+npP-hWz_XaPbi-5mzwnQ@mail.gmail.com>
Hi,
On Wed, Jun 28, 2023 at 07:28:54AM +0800, sun yq wrote:
> Hi,
> Because there are many functions using the plane, increasing the max
> number of the plane is to maximize the solution to all possible oob
> places.
I don't think it is the right approach then. If the HW is only handling
3 planes, there should be no reason to have to allocate for 8 planes. I
suspect that this 8 value is coming from the maximum allowed plane
number in V4L2 right ?
INHO driver should simply be fixed to ensure that num_plane won't go
higher than the real number of plane allocated in the structures.
It should be possible to get the num_plane value from the format
selected.
Alain
>
> On Tue, Jun 27, 2023 at 10:06 PM Alain Volmat <alain.volmat@foss.st.com> wrote:
> >
> > Hi,
> >
> > On Tue, Jun 27, 2023 at 04:27:31PM +0800, yqsun1997@gmail.com wrote:
> > > From: yqsun1997 <yqsun1997@gmail.com>
> > >
> > > Because format in struct img_image_buffer max index is IMG_MAX_PLANES ==3,
> > > The num_planes max index is 8.so will be OOB like in mdp_prepare_buffer.
> >
> > Similarly as your other patch, could you describe why you need to
> > increase the IMG_MAX_PLANES while I suspect your driver only needs to
> > deal with 3 planes. While the maximum num_planes value that can be
> > given by the user is 8, this has to be first compared to the configured
> > format prior to reaching this function.
> >
> > >
> > > static void mdp_prepare_buffer(struct img_image_buffer *b,
> > > struct mdp_frame *frame, struct vb2_buffer *vb)
> > > {
> > > struct v4l2_pix_format_mplane *pix_mp = &frame->format.fmt.pix_mp;
> > > unsigned int i;
> > >
> > > b->format.colorformat = frame->mdp_fmt->mdp_color;
> > > b->format.ycbcr_prof = frame->ycbcr_prof;
> > > for (i = 0; i < pix_mp->num_planes; ++i) {
> > > u32 stride = mdp_fmt_get_stride(frame->mdp_fmt,
> > > pix_mp->plane_fmt[i].bytesperline, i);
> > >
> > > b->format.plane_fmt[i].stride = stride; //oob
> > > ......
> > >
> > > Signed-off-by: yqsun1997 <yqsun1997@gmail.com>
> > > ---
> > > drivers/media/platform/mediatek/mdp3/mtk-mdp3-type.h | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-type.h b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-type.h
> > > index ae0396806..e2e991a34 100644
> > > --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-type.h
> > > +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-type.h
> > > @@ -11,7 +11,7 @@
> > >
> > > #define IMG_MAX_HW_INPUTS 3
> > > #define IMG_MAX_HW_OUTPUTS 4
> > > -#define IMG_MAX_PLANES 3
> > > +#define IMG_MAX_PLANES 8
> > > #define IMG_MAX_COMPONENTS 20
> > >
> > > struct img_crop {
> > > --
> > > 2.39.2
> > >
> >
> > Regards,
> > Alain
next prev parent reply other threads:[~2023-06-28 8:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-27 8:27 yqsun1997
2023-06-27 14:06 ` Alain Volmat
2023-06-27 23:28 ` sun yq
2023-06-28 6:33 ` Alain Volmat [this message]
2023-06-28 10:09 ` sun yq
2023-06-28 15:13 ` Chen-Yu Tsai
2023-06-29 7:18 ` Hans Verkuil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230628063353.GA3625616@gnbcxd0016.gnb.st.com \
--to=alain.volmat@foss.st.com \
--cc=499671216@qq.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=yqsun1997@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®