All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm: core: fix no null pointer detection in ofnode_get_addr_size_index()
@ 2021-05-13  7:38 chenguanqiao
  2021-05-15 15:20 ` Simon Glass
  0 siblings, 1 reply; 3+ messages in thread
From: chenguanqiao @ 2021-05-13  7:38 UTC (permalink / raw)
  To: u-boot

From: Chen Guanqiao <chenguanqiao@kuaishou.com>

Fixed a defect of a null pointer being discovered by Coverity Scan:
   CID 331544:  Null pointer dereferences  (REVERSE_INULL)
   Null-checking "size" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.

Signed-off-by: Chen Guanqiao <chenguanqiao@kuaishou.com>
---
 drivers/core/ofnode.c | 13 +++++++------
 include/dm/ofnode.h   |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 6c771e364f..554af95114 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -299,11 +299,10 @@ ofnode ofnode_get_by_phandle(uint phandle)
 	return node;
 }

-fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size)
+fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *psize)
 {
 	int na, ns;
-
-	*size = FDT_SIZE_T_NONE;
+	fdt_size_t size = FDT_SIZE_T_NONE;

 	if (ofnode_is_np(node)) {
 		const __be32 *prop_val;
@@ -314,8 +313,7 @@ fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size)
 					  &flags);
 		if (!prop_val)
 			return FDT_ADDR_T_NONE;
-		if (size)
-			*size = size64;
+		size = size64;

 		ns = of_n_size_cells(ofnode_to_np(node));

@@ -330,9 +328,12 @@ fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size)
 		ns = ofnode_read_simple_size_cells(ofnode_get_parent(node));
 		return fdtdec_get_addr_size_fixed(gd->fdt_blob,
 						  ofnode_to_offset(node), "reg",
-						  index, na, ns, size, true);
+						  index, na, ns, psize, true);
 	}

+	if (size)
+		*psize = size;
+
 	return FDT_ADDR_T_NONE;
 }

diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 8a69fd87da..e38d39dcf3 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -487,7 +487,7 @@ int ofnode_read_size(ofnode node, const char *propname);
  * @return address, or FDT_ADDR_T_NONE if not present or invalid
  */
 phys_addr_t ofnode_get_addr_size_index(ofnode node, int index,
-				       fdt_size_t *size);
+				       fdt_size_t *psize);

 /**
  * ofnode_get_addr_index() - get an address from a node
--
2.27.0

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

* [PATCH] dm: core: fix no null pointer detection in ofnode_get_addr_size_index()
  2021-05-13  7:38 [PATCH] dm: core: fix no null pointer detection in ofnode_get_addr_size_index() chenguanqiao
@ 2021-05-15 15:20 ` Simon Glass
  2021-07-04 19:24   ` Simon Glass
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Glass @ 2021-05-15 15:20 UTC (permalink / raw)
  To: u-boot

On Thu, 13 May 2021 at 01:38, chenguanqiao <chenguanqiao@kuaishou.com> wrote:
>
> From: Chen Guanqiao <chenguanqiao@kuaishou.com>
>
> Fixed a defect of a null pointer being discovered by Coverity Scan:
>    CID 331544:  Null pointer dereferences  (REVERSE_INULL)
>    Null-checking "size" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
>
> Signed-off-by: Chen Guanqiao <chenguanqiao@kuaishou.com>
> ---
>  drivers/core/ofnode.c | 13 +++++++------
>  include/dm/ofnode.h   |  2 +-
>  2 files changed, 8 insertions(+), 7 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* Re: [PATCH] dm: core: fix no null pointer detection in ofnode_get_addr_size_index()
  2021-05-15 15:20 ` Simon Glass
@ 2021-07-04 19:24   ` Simon Glass
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Glass @ 2021-07-04 19:24 UTC (permalink / raw)
  To: chenguanqiao; +Cc: U-Boot Mailing List

Hi Chenguanqiao,

On Sat, 15 May 2021 at 09:20, Simon Glass <sjg@chromium.org> wrote:
>
> On Thu, 13 May 2021 at 01:38, chenguanqiao <chenguanqiao@kuaishou.com> wrote:
> >
> > From: Chen Guanqiao <chenguanqiao@kuaishou.com>
> >
> > Fixed a defect of a null pointer being discovered by Coverity Scan:
> >    CID 331544:  Null pointer dereferences  (REVERSE_INULL)
> >    Null-checking "size" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
> >
> > Signed-off-by: Chen Guanqiao <chenguanqiao@kuaishou.com>
> > ---
> >  drivers/core/ofnode.c | 13 +++++++------
> >  include/dm/ofnode.h   |  2 +-
> >  2 files changed, 8 insertions(+), 7 deletions(-)
> >
>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Unfortunately this does not apply to u-boot/next. Can you please
rebase it and resend?

Regards,
Simon

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

end of thread, other threads:[~2021-07-04 19:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13  7:38 [PATCH] dm: core: fix no null pointer detection in ofnode_get_addr_size_index() chenguanqiao
2021-05-15 15:20 ` Simon Glass
2021-07-04 19:24   ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.