Skip to content

Commit 9540901

Browse files
YueHaibinggregkh
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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent da97a80 commit 9540901

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
@@ -222,8 +222,10 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
222222
ptp->dev = device_create_with_groups(ptp_class, parent, ptp->devid,
223223
ptp, ptp->pin_attr_groups,
224224
"ptp%d", ptp->index);
225-
if (IS_ERR(ptp->dev))
225+
if (IS_ERR(ptp->dev)) {
226+
err = PTR_ERR(ptp->dev);
226227
goto no_device;
228+
}
227229

228230
/* Register a new PPS source. */
229231
if (info->pps) {
@@ -234,6 +236,7 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,
234236
pps.owner = info->owner;
235237
ptp->pps_source = pps_register_source(&pps, PTP_PPS_DEFAULTS);
236238
if (!ptp->pps_source) {
239+
err = -EINVAL;
237240
pr_err("failed to register pps source\n");
238241
goto no_pps;
239242
}

0 commit comments

Comments
 (0)