svn commit: r331734 - stable/10/sys/dev/jedec_dimm

Ravi Pokala rpokala at FreeBSD.org
Thu Mar 29 15:01:02 UTC 2018


Author: rpokala
Date: Thu Mar 29 15:01:01 2018
New Revision: 331734
URL: https://svnweb.freebsd.org/changeset/base/331734

Log:
  MFC 331345:
  
  jedec_dimm: Use correct string length when populating sc->slotid_str
  
  Don't limit the copy to the size of the target string *pointer* (always
  4 on 32-bit / 8 on 64-bit). Instead, just use strdup().

Modified:
  stable/10/sys/dev/jedec_dimm/jedec_dimm.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/jedec_dimm/jedec_dimm.c
==============================================================================
--- stable/10/sys/dev/jedec_dimm/jedec_dimm.c	Thu Mar 29 15:00:48 2018	(r331733)
+++ stable/10/sys/dev/jedec_dimm/jedec_dimm.c	Thu Mar 29 15:01:01 2018	(r331734)
@@ -341,10 +341,7 @@ jedec_dimm_attach(device_t dev)
 	if (resource_string_value(device_get_name(dev), device_get_unit(dev),
 	    "slotid", &slotid_str) == 0) {
 		if (slotid_str != NULL) {
-			sc->slotid_str = malloc(strlen(slotid_str) + 1,
-			    M_DEVBUF, (M_WAITOK | M_ZERO));
-			strlcpy(sc->slotid_str, slotid_str,
-			    sizeof(sc->slotid_str));
+			sc->slotid_str = strdup(slotid_str, M_DEVBUF);
 			SYSCTL_ADD_STRING(ctx, children, OID_AUTO, "slotid",
 			    CTLFLAG_RD | CTLFLAG_MPSAFE, sc->slotid_str, 0,
 			    "DIMM Slot Identifier");


More information about the svn-src-stable mailing list