[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAKwoAfqFbZ0rWzYwX+WTJzMUE1K1Es_UtZj6YXwDKqs=HR6f5g@mail.gmail.com>
Date: Thu, 12 Dec 2024 10:34:24 +0100
From: Karol P <karprzy7@...il.com>
To: Laurent Pinchart <laurent.pinchart@...asonboard.com>
Cc: tomi.valkeinen@...asonboard.com, maarten.lankhorst@...ux.intel.com,
mripard@...nel.org, tzimmermann@...e.de, airlied@...il.com, simona@...ll.ch,
michal.simek@....com, dri-devel@...ts.freedesktop.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm: zynqmp_dp: Fix integer overflow in zynqmp_dp_rate_get()
On Wed, 11 Dec 2024 at 13:59, Laurent Pinchart
<laurent.pinchart@...asonboard.com> wrote:
>
> Hi Karol,
>
> Thank you for the patch.
>
> On Wed, Dec 11, 2024 at 01:20:26PM +0100, Karol Przybylski wrote:
> > This patch fixes a potential integer overflow in the zynqmp_dp_rate_get() function.
> >
> > The issue comes up when the expression drm_dp_bw_code_to_link_rate(dp->test.bw_code) * 10000 is evaluated using 32-bit arithmetic.
>
> Please wrap your commit message text to 82 columns.
>
> >
> > Now the constant is casted to compatible u64 type.
> >
> > Resolves CID 1636340 and CID 1635811
> >
>
> Does this need a Fixes: tag ? How about 'Cc: stable@...r.kernel.org' to
> get it backported to stable kernels ?
Thanks for the feedback, I'll add it.
>
> > Signed-off-by: Karol Przybylski <karprzy7@...il.com>
> > ---
> > drivers/gpu/drm/xlnx/zynqmp_dp.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
> > index 25c5dc61e..55e92344b 100644
> > --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
> > +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
> > @@ -2190,7 +2190,7 @@ static int zynqmp_dp_rate_get(void *data, u64 *val)
> > struct zynqmp_dp *dp = data;
> >
> > mutex_lock(&dp->lock);
> > - *val = drm_dp_bw_code_to_link_rate(dp->test.bw_code) * 10000;
> > + *val = drm_dp_bw_code_to_link_rate(dp->test.bw_code) * (u64)10000;
>
> You can also make the integer a 64-bit constant with
>
> *val = drm_dp_bw_code_to_link_rate(dp->test.bw_code) * 10000ULL;
>
> > mutex_unlock(&dp->lock);
> > return 0;
> > }
It does look better. I will send v2 of this patch.
>
> --
> Regards,
>
> Laurent Pinchart
Powered by blists - more mailing lists