From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758651AbbEaWpu (ORCPT ); Sun, 31 May 2015 18:45:50 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:59066 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751272AbbEaWpt (ORCPT ); Sun, 31 May 2015 18:45:49 -0400 From: Colin King To: Greg Kroah-Hartman , Laurent Pinchart , Felipe Balbi , Sudeep Holla , linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH][V2] usb: isp1760: fix null dereference if kzalloc returns null Date: Sun, 31 May 2015 23:43:43 +0100 Message-Id: <1433112223-4651-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King If kzalloc returns null then isp1760_ep_alloc_request performs a null pointer dereference on req. Check for null to avoid this. Detected with smatch static analysis: drivers/usb/isp1760/isp1760-udc.c:816 isp1760_ep_alloc_request() error: potential null dereference 'req'. (kzalloc returns null) Signed-off-by: Colin Ian King --- drivers/usb/isp1760/isp1760-udc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c index 3fc4fe7..18ebf5b 100644 --- a/drivers/usb/isp1760/isp1760-udc.c +++ b/drivers/usb/isp1760/isp1760-udc.c @@ -812,6 +812,8 @@ static struct usb_request *isp1760_ep_alloc_request(struct usb_ep *ep, struct isp1760_request *req; req = kzalloc(sizeof(*req), gfp_flags); + if (!req) + return NULL; return &req->req; } -- 2.1.4