Skip to content

Commit

Permalink
ptp: ocp: Fix a couple NULL vs IS_ERR() checks
Browse files Browse the repository at this point in the history
The ptp_ocp_get_mem() function does not return NULL, it returns error
pointers.

Fixes: 773bda9 ("ptp: ocp: Expose various resources on the timecard.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dan Carpenter authored and David S. Miller committed Nov 18, 2021
1 parent 0fa68da commit c7521d3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions drivers/ptp/ptp_ocp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1304,10 +1304,11 @@ ptp_ocp_register_ext(struct ptp_ocp *bp, struct ocp_resource *r)
if (!ext)
return -ENOMEM;

err = -EINVAL;
ext->mem = ptp_ocp_get_mem(bp, r);
if (!ext->mem)
if (IS_ERR(ext->mem)) {
err = PTR_ERR(ext->mem);
goto out;
}

ext->bp = bp;
ext->info = r->extra;
Expand Down Expand Up @@ -1371,8 +1372,8 @@ ptp_ocp_register_mem(struct ptp_ocp *bp, struct ocp_resource *r)
void __iomem *mem;

mem = ptp_ocp_get_mem(bp, r);
if (!mem)
return -EINVAL;
if (IS_ERR(mem))
return PTR_ERR(mem);

bp_assign_entry(bp, r, mem);

Expand Down

0 comments on commit c7521d3

Please sign in to comment.