From owner-svn-src-all@freebsd.org Thu Mar 29 15:00:49 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15F08F51DEE; Thu, 29 Mar 2018 15:00:49 +0000 (UTC) (envelope-from rpokala@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BD77772445; Thu, 29 Mar 2018 15:00:48 +0000 (UTC) (envelope-from rpokala@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B83BF1B5EC; Thu, 29 Mar 2018 15:00:48 +0000 (UTC) (envelope-from rpokala@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2TF0mdo041653; Thu, 29 Mar 2018 15:00:48 GMT (envelope-from rpokala@FreeBSD.org) Received: (from rpokala@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2TF0m5W041640; Thu, 29 Mar 2018 15:00:48 GMT (envelope-from rpokala@FreeBSD.org) Message-Id: <201803291500.w2TF0m5W041640@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rpokala set sender to rpokala@FreeBSD.org using -f From: Ravi Pokala Date: Thu, 29 Mar 2018 15:00:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331733 - stable/11/sys/dev/jedec_dimm X-SVN-Group: stable-11 X-SVN-Commit-Author: rpokala X-SVN-Commit-Paths: stable/11/sys/dev/jedec_dimm X-SVN-Commit-Revision: 331733 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Mar 2018 15:00:49 -0000 Author: rpokala Date: Thu Mar 29 15:00:48 2018 New Revision: 331733 URL: https://svnweb.freebsd.org/changeset/base/331733 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/11/sys/dev/jedec_dimm/jedec_dimm.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/jedec_dimm/jedec_dimm.c ============================================================================== --- stable/11/sys/dev/jedec_dimm/jedec_dimm.c Thu Mar 29 14:27:40 2018 (r331732) +++ stable/11/sys/dev/jedec_dimm/jedec_dimm.c Thu Mar 29 15:00:48 2018 (r331733) @@ -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");