Skip to content

Commit 4561df9

Browse files
YueHaibingbwhacks
YueHaibing
authored andcommitted
ptp: Fix pass zero to ERR_PTR() in ptp_clock_register
commit aea0a89 upstream. Fix smatch warning: drivers/ptp/ptp_clock.c:298 ptp_clock_register() warn: passing zero to 'ERR_PTR' 'err' should be set while device_create_with_groups and pps_register_source fails Fixes: 85a66e5 ("ptp: create "pins" together with the rest of attributes") Signed-off-by: YueHaibing <[email protected]> Acked-by: Richard Cochran <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Ben Hutchings <[email protected]>
1 parent f78b54e commit 4561df9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/ptp/ptp_clock.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,10 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
218218
ptp->dev = device_create_with_groups(ptp_class, parent, ptp->devid,
219219
ptp, ptp->pin_attr_groups,
220220
"ptp%d", ptp->index);
221-
if (IS_ERR(ptp->dev))
221+
if (IS_ERR(ptp->dev)) {
222+
err = PTR_ERR(ptp->dev);
222223
goto no_device;
224+
}
223225

224226
/* Register a new PPS source. */
225227
if (info->pps) {
@@ -230,6 +232,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
230232
pps.owner = info->owner;
231233
ptp->pps_source = pps_register_source(&pps, PTP_PPS_DEFAULTS);
232234
if (!ptp->pps_source) {
235+
err = -EINVAL;
233236
pr_err("failed to register pps source\n");
234237
goto no_pps;
235238
}

0 commit comments

Comments
 (0)