Skip to contentSkip to conversation

drivers: remoteproc: rproc-uclass: Fix check for NULL pointers

PATCH In review Nishanth Menon 2 participants 2 messages Dec 1, 2015 – Dec 6, 2015 Remote processor (remoteproc)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: remoteproc: rproc-uclass: Fix check for NULL pointers

Neither uc_pdata->name nor check_name are supposed to be NULL in _rproc_name_is_unique(). if uc_pdata->name is NULL, we are not intialized yet, however if check_data is NULL, we do not have proper data. Further, if either were NULL, strlen will crap out while attempting to derefence NULL.

Instead, just check if either of these are NULL and bail out.

This should also fix the following coverity scan warnings:
*** CID 132281: Null pointer dereferences (FORWARD_NULL) /drivers/remoteproc/rproc-uclass.c: 73 in _rproc_name_is_unique()

---
Test log: http://pastebin.ubuntu.com/13591420/

 drivers/remoteproc/rproc-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/rproc-uclass.c +1 -1
index a421e12e5d16..200cf61bc948 100644
@@ -66,7 +66,7 @@ static int _rproc_name_is_unique(struct udevice *dev,
 	const char *check_name = data;
 
 	/* devices not yet populated with data - so skip them */
-	if (!uc_pdata->name && check_name)
+	if (!uc_pdata->name || !check_name)
 		return 0;
 
 	/* Return 0 to search further if we dont match */
Signature · 1 line
2.6.2.402.g2635c2b
#1 lore raw
Quoted 6 lines · Nishanth Menon

Neither uc_pdata->name nor check_name are supposed to be NULL in _rproc_name_is_unique(). if uc_pdata->name is NULL, we are not intialized yet, however if check_data is NULL, we do not have proper data. Further, if either were NULL, strlen will crap out while attempting to derefence NULL.

Quoted 8 lines

Instead, just check if either of these are NULL and bail out.

This should also fix the following coverity scan warnings:
*** CID 132281: Null pointer dereferences (FORWARD_NULL) /drivers/remoteproc/rproc-uclass.c: 73 in _rproc_name_is_unique()

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151206/76332585/attachment.sig>