> On Jul 23, 2017, at 10:05 AM, Florian Fainelli wrote: >> + >> + strncpy(drvinfo->version, HNAE_DRIVER_VERSION, >> + sizeof(drvinfo->version)); >> + drvinfo->version[sizeof(drvinfo->version) - 1] = '\0'; > > strlcpy() would probably do that for you. You need to be careful about strlcpy - it does not completely write the destination buffer as strncpy does, and so can result in a kernel memory leak if the destination is not known to already be cleared. >> + >> + strncpy(drvinfo->driver, HNAE_DRIVER_NAME, sizeof(drvinfo->driver)); >> + drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0'; > > Same here Same here >> + >> + strncpy(drvinfo->bus_info, priv->dev->bus->name, >> + sizeof(drvinfo->bus_info));> + drvinfo->bus_info[ETHTOOL_BUSINFO_LEN - 1] = '\0'; > > And here. And here too. I haven't looked at this deeply enough to know whether a leak could be created by strlcpy here, but I wanted to raise it as something to be considered before switching to it. Blindly adopting strlcpy is hazardous as are tools that unconditionally recommend it. -- Mark Rustad, Networking Division, Intel Corporation