Skip to content

Commit

Permalink
net/smc: fix invalid return code in smcd_new_buf_create()
Browse files Browse the repository at this point in the history
smc_ism_register_dmb() returns error codes set by the ISM driver which
are not guaranteed to be negative or in the errno range. Such values
would not be handled by ERR_PTR() and finally the return code will be
used as a memory address.
Fix that by using a valid negative errno value with ERR_PTR().

Fixes: 72b7f6c ("net/smc: unique reason code for exceeded max dmb count")
Signed-off-by: Karsten Graul <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
karstengr authored and kuba-moo committed Oct 15, 2020
1 parent ef12ad4 commit 6b1bbf9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/smc/smc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,8 @@ static struct smc_buf_desc *smcd_new_buf_create(struct smc_link_group *lgr,
rc = smc_ism_register_dmb(lgr, bufsize, buf_desc);
if (rc) {
kfree(buf_desc);
return (rc == -ENOMEM) ? ERR_PTR(-EAGAIN) : ERR_PTR(rc);
return (rc == -ENOMEM) ? ERR_PTR(-EAGAIN) :
ERR_PTR(-EIO);
}
buf_desc->pages = virt_to_page(buf_desc->cpu_addr);
/* CDC header stored in buf. So, pretend it was smaller */
Expand Down

0 comments on commit 6b1bbf9

Please sign in to comment.