Commit d40a0946 authored by Eric Biggers's avatar Eric Biggers Committed by Greg Kroah-Hartman

misc: mic: fix incorrect use of error codes in SCIF DMA driver

The error code passed to ERR_PTR() always should be negated.  Also, the
return value of scif_add_mmu_notifier() was never checked.
Signed-off-by: default avatarEric Biggers <ebiggers3@gmail.com>
Reviewed-by: default avatarSudeep Dutt <sudeep.dutt@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0d0ce9c0
...@@ -271,13 +271,10 @@ static struct scif_mmu_notif * ...@@ -271,13 +271,10 @@ static struct scif_mmu_notif *
scif_find_mmu_notifier(struct mm_struct *mm, struct scif_endpt_rma_info *rma) scif_find_mmu_notifier(struct mm_struct *mm, struct scif_endpt_rma_info *rma)
{ {
struct scif_mmu_notif *mmn; struct scif_mmu_notif *mmn;
struct list_head *item;
list_for_each(item, &rma->mmn_list) { list_for_each_entry(mmn, &rma->mmn_list, list)
mmn = list_entry(item, struct scif_mmu_notif, list);
if (mmn->mm == mm) if (mmn->mm == mm)
return mmn; return mmn;
}
return NULL; return NULL;
} }
...@@ -288,13 +285,12 @@ scif_add_mmu_notifier(struct mm_struct *mm, struct scif_endpt *ep) ...@@ -288,13 +285,12 @@ scif_add_mmu_notifier(struct mm_struct *mm, struct scif_endpt *ep)
= kzalloc(sizeof(*mmn), GFP_KERNEL); = kzalloc(sizeof(*mmn), GFP_KERNEL);
if (!mmn) if (!mmn)
return ERR_PTR(ENOMEM); return ERR_PTR(-ENOMEM);
scif_init_mmu_notifier(mmn, current->mm, ep); scif_init_mmu_notifier(mmn, current->mm, ep);
if (mmu_notifier_register(&mmn->ep_mmu_notifier, if (mmu_notifier_register(&mmn->ep_mmu_notifier, current->mm)) {
current->mm)) {
kfree(mmn); kfree(mmn);
return ERR_PTR(EBUSY); return ERR_PTR(-EBUSY);
} }
list_add(&mmn->list, &ep->rma_info.mmn_list); list_add(&mmn->list, &ep->rma_info.mmn_list);
return mmn; return mmn;
...@@ -1725,7 +1721,7 @@ static int scif_rma_copy(scif_epd_t epd, off_t loffset, unsigned long addr, ...@@ -1725,7 +1721,7 @@ static int scif_rma_copy(scif_epd_t epd, off_t loffset, unsigned long addr,
mutex_lock(&ep->rma_info.mmn_lock); mutex_lock(&ep->rma_info.mmn_lock);
mmn = scif_find_mmu_notifier(current->mm, &ep->rma_info); mmn = scif_find_mmu_notifier(current->mm, &ep->rma_info);
if (!mmn) if (!mmn)
scif_add_mmu_notifier(current->mm, ep); mmn = scif_add_mmu_notifier(current->mm, ep);
mutex_unlock(&ep->rma_info.mmn_lock); mutex_unlock(&ep->rma_info.mmn_lock);
if (IS_ERR(mmn)) { if (IS_ERR(mmn)) {
scif_put_peer_dev(spdev); scif_put_peer_dev(spdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment