Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754873AbbLLCxT (ORCPT ); Fri, 11 Dec 2015 21:53:19 -0500 Received: from mga09.intel.com ([134.134.136.24]:8548 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754451AbbLLCxQ (ORCPT ); Fri, 11 Dec 2015 21:53:16 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,416,1444719600"; d="scan'208";a="616739887" Subject: Re: [PATCH] misc: mic: fix incorrect use of error codes in SCIF DMA driver From: Sudeep Dutt To: Eric Biggers Cc: Sudeep Dutt , ashutosh.dixit@intel.com, nikhil.rao@intel.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org In-Reply-To: <1449886156-11667-1-git-send-email-ebiggers3@gmail.com> References: <1449886156-11667-1-git-send-email-ebiggers3@gmail.com> Content-Type: text/plain; charset="UTF-8" Date: Fri, 11 Dec 2015 18:50:41 -0800 Message-ID: <1449888641.93285.549.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-30.el6) Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2288 Lines: 66 On Fri, 2015-12-11 at 20:09 -0600, Eric Biggers wrote: > The error code passed to ERR_PTR() always should be negated. Also, the > return value of scif_add_mmu_notifier() was never checked. > Thanks for the patch Eric. Reviewed-by: Sudeep Dutt > Signed-off-by: Eric Biggers > --- > drivers/misc/mic/scif/scif_dma.c | 14 +++++--------- > 1 file changed, 5 insertions(+), 9 deletions(-) > > diff --git a/drivers/misc/mic/scif/scif_dma.c b/drivers/misc/mic/scif/scif_dma.c > index 95a13c6..f6aeebd 100644 > --- a/drivers/misc/mic/scif/scif_dma.c > +++ b/drivers/misc/mic/scif/scif_dma.c > @@ -276,13 +276,10 @@ static struct scif_mmu_notif * > scif_find_mmu_notifier(struct mm_struct *mm, struct scif_endpt_rma_info *rma) > { > struct scif_mmu_notif *mmn; > - struct list_head *item; > > - list_for_each(item, &rma->mmn_list) { > - mmn = list_entry(item, struct scif_mmu_notif, list); > + list_for_each_entry(mmn, &rma->mmn_list, list) > if (mmn->mm == mm) > return mmn; > - } > return NULL; > } > > @@ -293,13 +290,12 @@ scif_add_mmu_notifier(struct mm_struct *mm, struct scif_endpt *ep) > = kzalloc(sizeof(*mmn), GFP_KERNEL); > > if (!mmn) > - return ERR_PTR(ENOMEM); > + return ERR_PTR(-ENOMEM); > > scif_init_mmu_notifier(mmn, current->mm, ep); > - if (mmu_notifier_register(&mmn->ep_mmu_notifier, > - current->mm)) { > + if (mmu_notifier_register(&mmn->ep_mmu_notifier, current->mm)) { > kfree(mmn); > - return ERR_PTR(EBUSY); > + return ERR_PTR(-EBUSY); > } > list_add(&mmn->list, &ep->rma_info.mmn_list); > return mmn; > @@ -1730,7 +1726,7 @@ static int scif_rma_copy(scif_epd_t epd, off_t loffset, unsigned long addr, > mutex_lock(&ep->rma_info.mmn_lock); > mmn = scif_find_mmu_notifier(current->mm, &ep->rma_info); > if (!mmn) > - scif_add_mmu_notifier(current->mm, ep); > + mmn = scif_add_mmu_notifier(current->mm, ep); > mutex_unlock(&ep->rma_info.mmn_lock); > if (IS_ERR(mmn)) { > scif_put_peer_dev(spdev); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/