Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756213AbcKCNQs (ORCPT ); Thu, 3 Nov 2016 09:16:48 -0400 Received: from mail.ispras.ru ([83.149.199.45]:56908 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753975AbcKCNQq (ORCPT ); Thu, 3 Nov 2016 09:16:46 -0400 From: Alexey Khoroshilov To: Felipe Balbi Cc: Alexey Khoroshilov , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH v2 1/2] usb: gadget: mv_u3d: add check for dma mapping error Date: Thu, 3 Nov 2016 16:16:31 +0300 Message-Id: <1478178992-28317-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <871sytndwo.fsf@linux.intel.com> References: <871sytndwo.fsf@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 894 Lines: 29 mv_u3d_req_to_trb() does not check for dma mapping errors. Found by Linux Driver Verification project (linuxtesting.org). v2: split fix and clenup to separate patches. Signed-off-by: Alexey Khoroshilov --- drivers/usb/gadget/udc/mv_u3d_core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c index b9e19a591322..6f3be0ba9ac8 100644 --- a/drivers/usb/gadget/udc/mv_u3d_core.c +++ b/drivers/usb/gadget/udc/mv_u3d_core.c @@ -462,6 +462,12 @@ static int mv_u3d_req_to_trb(struct mv_u3d_req *req) req->trb_head->trb_hw, trb_num * sizeof(*trb_hw), DMA_BIDIRECTIONAL); + if (dma_mapping_error(u3d->gadget.dev.parent, + req->trb_head->trb_dma)) { + kfree(req->trb_head->trb_hw); + kfree(req->trb_head); + return -EFAULT; + } req->chain = 1; } -- 2.7.4