public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@nxp.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 3/3] drivers: core: use strcmp when find device by name
Date: Wed, 22 May 2019 07:08:14 +0000	[thread overview]
Message-ID: <20190522072201.5130-3-peng.fan@nxp.com> (raw)
In-Reply-To: <20190522072201.5130-1-peng.fan@nxp.com>

`if (!strncmp(dev->name, name, strlen(name)))` might find out
the wrong device, it might find out `dram_pll_ref_sel`, when name is
`dram_pll`. So use strcmp to avoid such issue.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

V2:
 None

 drivers/core/uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index fc3157de39..e2f35393a9 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -260,7 +260,7 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,
 		return ret;
 
 	uclass_foreach_dev(dev, uc) {
-		if (!strncmp(dev->name, name, strlen(name))) {
+		if (!strcmp(dev->name, name)) {
 			*devp = dev;
 			return 0;
 		}
-- 
2.16.4

  parent reply	other threads:[~2019-05-22  7:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22  7:08 [U-Boot] [PATCH V2 1/3] test: dm: adc: use the real device name Peng Fan
2019-05-22  7:08 ` [U-Boot] [PATCH V2 2/3] test: dm: usb: " Peng Fan
2019-05-22  7:50   ` Bin Meng
2019-07-14 13:07   ` Tom Rini
2019-05-22  7:08 ` Peng Fan [this message]
2019-05-22  7:50   ` [U-Boot] [PATCH V2 3/3] drivers: core: use strcmp when find device by name Bin Meng
2019-07-14 13:07   ` Tom Rini
2019-05-22  7:49 ` [U-Boot] [PATCH V2 1/3] test: dm: adc: use the real device name Bin Meng
2019-06-19  2:17 ` Peng Fan
2019-06-24 15:52   ` Tom Rini
2019-06-25  5:45     ` Peng Fan
2019-07-14 13:06 ` Tom Rini

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=20190522072201.5130-3-peng.fan@nxp.com \
    --to=peng.fan@nxp.com \
    --cc=u-boot@lists.denx.de \
    /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