public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: ufshcd-pltfrm: Signedness bug in ufshcd_parse_clock_info()
@ 2024-08-15 11:24 Dan Carpenter
  2024-08-15 17:47 ` Bart Van Assche
  2024-08-17  1:07 ` Martin K. Petersen
  0 siblings, 2 replies; 6+ messages in thread
From: Dan Carpenter @ 2024-08-15 11:24 UTC (permalink / raw)
  To: Rob Herring
  Cc: James E.J. Bottomley, Martin K. Petersen, Manivannan Sadhasivam,
	Bart Van Assche, Krzysztof Kozlowski, Brian Masney, Nitin Rawat,
	Can Guo, linux-scsi, linux-kernel, kernel-janitors

The "sz" variable needs to be a signed type for the error handling to
work as intended.  Fortunately, there is some sanity checking on "sz" on
the next line, so negative values would be caught and it doesn't really
affect runtime.

Fixes: eab0dce11dd9 ("scsi: ufs: ufshcd-pltfrm: Use of_property_count_u32_elems() to get property length")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/ufs/host/ufshcd-pltfrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ufs/host/ufshcd-pltfrm.c b/drivers/ufs/host/ufshcd-pltfrm.c
index 0c9b303ccfa0..1f4f30d6cb42 100644
--- a/drivers/ufs/host/ufshcd-pltfrm.c
+++ b/drivers/ufs/host/ufshcd-pltfrm.c
@@ -31,7 +31,7 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
 	const char *name;
 	u32 *clkfreq = NULL;
 	struct ufs_clk_info *clki;
-	size_t sz = 0;
+	ssize_t sz = 0;
 
 	if (!np)
 		goto out;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: ufs: ufshcd-pltfrm: Signedness bug in ufshcd_parse_clock_info()
  2024-08-15 11:24 [PATCH] scsi: ufs: ufshcd-pltfrm: Signedness bug in ufshcd_parse_clock_info() Dan Carpenter
@ 2024-08-15 17:47 ` Bart Van Assche
  2024-08-15 21:35   ` Dan Carpenter
  2024-08-17  1:07 ` Martin K. Petersen
  1 sibling, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2024-08-15 17:47 UTC (permalink / raw)
  To: Dan Carpenter, Rob Herring
  Cc: James E.J. Bottomley, Martin K. Petersen, Manivannan Sadhasivam,
	Krzysztof Kozlowski, Brian Masney, Nitin Rawat, Can Guo,
	linux-scsi, linux-kernel, kernel-janitors

On 8/15/24 4:24 AM, Dan Carpenter wrote:
> The "sz" variable needs to be a signed type for the error handling to
> work as intended.

What error handling are you referring to? I haven't found any code that
assigns a negative value to 'sz' in ufshcd_parse_clock_info(). Did I
perhaps overlook something?

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: ufs: ufshcd-pltfrm: Signedness bug in ufshcd_parse_clock_info()
  2024-08-15 17:47 ` Bart Van Assche
@ 2024-08-15 21:35   ` Dan Carpenter
  2024-08-16  6:34     ` Manivannan Sadhasivam
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2024-08-15 21:35 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Rob Herring, James E.J. Bottomley, Martin K. Petersen,
	Manivannan Sadhasivam, Krzysztof Kozlowski, Brian Masney,
	Nitin Rawat, Can Guo, linux-scsi, linux-kernel, kernel-janitors

On Thu, Aug 15, 2024 at 10:47:30AM -0700, Bart Van Assche wrote:
> On 8/15/24 4:24 AM, Dan Carpenter wrote:
> > The "sz" variable needs to be a signed type for the error handling to
> > work as intended.
> 
> What error handling are you referring to? I haven't found any code that
> assigns a negative value to 'sz' in ufshcd_parse_clock_info(). Did I
> perhaps overlook something?
> 

Rob's patch in linux-next.

-       if (!of_get_property(np, "freq-table-hz", &len)) {
+       sz = of_property_count_u32_elems(np, "freq-table-hz");
+       if (sz <= 0) {
                dev_info(dev, "freq-table-hz property not specified\n");
                goto out;

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: ufs: ufshcd-pltfrm: Signedness bug in ufshcd_parse_clock_info()
  2024-08-15 21:35   ` Dan Carpenter
@ 2024-08-16  6:34     ` Manivannan Sadhasivam
  2024-08-16 11:46       ` Dan Carpenter
  0 siblings, 1 reply; 6+ messages in thread
From: Manivannan Sadhasivam @ 2024-08-16  6:34 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Bart Van Assche, Rob Herring, James E.J. Bottomley,
	Martin K. Petersen, Krzysztof Kozlowski, Brian Masney,
	Nitin Rawat, Can Guo, linux-scsi, linux-kernel, kernel-janitors

On Fri, Aug 16, 2024 at 12:35:22AM +0300, Dan Carpenter wrote:
> On Thu, Aug 15, 2024 at 10:47:30AM -0700, Bart Van Assche wrote:
> > On 8/15/24 4:24 AM, Dan Carpenter wrote:
> > > The "sz" variable needs to be a signed type for the error handling to
> > > work as intended.
> > 
> > What error handling are you referring to? I haven't found any code that
> > assigns a negative value to 'sz' in ufshcd_parse_clock_info(). Did I
> > perhaps overlook something?
> > 
> 
> Rob's patch in linux-next.
> 

It would've been helpful if you added 'next' in the patch subject prefix.

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

- Mani

> -       if (!of_get_property(np, "freq-table-hz", &len)) {
> +       sz = of_property_count_u32_elems(np, "freq-table-hz");
> +       if (sz <= 0) {
>                 dev_info(dev, "freq-table-hz property not specified\n");
>                 goto out;
> 
> regards,
> dan carpenter
> 

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: ufs: ufshcd-pltfrm: Signedness bug in ufshcd_parse_clock_info()
  2024-08-16  6:34     ` Manivannan Sadhasivam
@ 2024-08-16 11:46       ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2024-08-16 11:46 UTC (permalink / raw)
  To: Manivannan Sadhasivam
  Cc: Bart Van Assche, Rob Herring, James E.J. Bottomley,
	Martin K. Petersen, Krzysztof Kozlowski, Brian Masney,
	Nitin Rawat, Can Guo, linux-scsi, linux-kernel, kernel-janitors

On Fri, Aug 16, 2024 at 12:04:04PM +0530, Manivannan Sadhasivam wrote:
> On Fri, Aug 16, 2024 at 12:35:22AM +0300, Dan Carpenter wrote:
> > On Thu, Aug 15, 2024 at 10:47:30AM -0700, Bart Van Assche wrote:
> > > On 8/15/24 4:24 AM, Dan Carpenter wrote:
> > > > The "sz" variable needs to be a signed type for the error handling to
> > > > work as intended.
> > > 
> > > What error handling are you referring to? I haven't found any code that
> > > assigns a negative value to 'sz' in ufshcd_parse_clock_info(). Did I
> > > perhaps overlook something?
> > > 
> > 
> > Rob's patch in linux-next.
> > 
> 
> It would've been helpful if you added 'next' in the patch subject prefix.
> 

I guess that would helped in this case.  But most of the time when I see this
question it's because there are two different upstream maintainers modifying the
same code...  Anyway, sure, I can change my script to add "next" to the subject
when the FIXES_COMMIT isn't in Linus's tree.

if [ "$FIXES_COMMIT" != "" ] ; then
    if ! git merge-base --is-ancestor $FIXES_COMMIT origin/master ; then
        TREE=" next"
    fi
fi

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: ufs: ufshcd-pltfrm: Signedness bug in ufshcd_parse_clock_info()
  2024-08-15 11:24 [PATCH] scsi: ufs: ufshcd-pltfrm: Signedness bug in ufshcd_parse_clock_info() Dan Carpenter
  2024-08-15 17:47 ` Bart Van Assche
@ 2024-08-17  1:07 ` Martin K. Petersen
  1 sibling, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2024-08-17  1:07 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Rob Herring, James E.J. Bottomley, Martin K. Petersen,
	Manivannan Sadhasivam, Bart Van Assche, Krzysztof Kozlowski,
	Brian Masney, Nitin Rawat, Can Guo, linux-scsi, linux-kernel,
	kernel-janitors


Dan,

> The "sz" variable needs to be a signed type for the error handling to
> work as intended. Fortunately, there is some sanity checking on "sz"
> on the next line, so negative values would be caught and it doesn't
> really affect runtime.

Applied to 6.12/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-17  1:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-15 11:24 [PATCH] scsi: ufs: ufshcd-pltfrm: Signedness bug in ufshcd_parse_clock_info() Dan Carpenter
2024-08-15 17:47 ` Bart Van Assche
2024-08-15 21:35   ` Dan Carpenter
2024-08-16  6:34     ` Manivannan Sadhasivam
2024-08-16 11:46       ` Dan Carpenter
2024-08-17  1:07 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox