Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp199577imj; Thu, 14 Feb 2019 18:31:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IYdocCWAs1asbqDw2FGKiWd5h2SKiTMe2TysoIACwnLu1we9P1ztbZKilRZkXdE53DK+PGc X-Received: by 2002:a17:902:2bc9:: with SMTP id l67mr7683923plb.241.1550197908145; Thu, 14 Feb 2019 18:31:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197908; cv=none; d=google.com; s=arc-20160816; b=svLOQno7347gYzX2skHSYVvwWGqq5X+XfMjdvmH9BypSd94ejvA2/oYeTrpv3hESXi Lsl1MjBXkzGpnxNnXM/DZ1tz9vSGsXXBEQYK7o8efO5xGUigJWC5Lx4MMr/I16J1Acyu HRupwnDGoCCWaxAsmew0VYgA6/tctTPLLHl7iBl8dlRLbC3jK8s8Up1ag1iwXHUgEWh9 RSBbCsowwue/rdwoenS+hb5drYh6QBwJerkZ7DbmCkvsFpAlAUOCQuS/2fVxOaVwiaCX fro183547uQQHpfN4OJ7HnSb8DK9QjNbURY1aRZ81lkeyvSh770Rz8bKWePPKt/DiLpb YmcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QSSna3iZ4srFzEW2ajYDmQ0HwzXHQFVxMC77mFhPV8E=; b=P0+O50pwOEFPBCgaNX7IgLVCqQua8IMRktvRH5MsflQq2vPPT1/jZJFQeAXB99lWwF vjYsY4TNLAB+VFTnkEQaoDTsehRfG+E8ar4ywPgqsgaXGfziK4BVcz+3BduoDWs6GIr4 UlmydjGxieQK4eL6H7YKLE2T6UPYQjm0PdfRlxLHQdUGJBEqA3gmbDmHYYvwTnKs/G3o Q/LP4l9D+UgcR4uZG3blBBkXoVHLD59YOEi1fcUQ0kR8DRrOja4KWB+SI6A2Q07opvp3 BUMPd1LAldVkwuhpcPpWPLcJLFKdEqjR4o0Q0F4H6FGjnDkaV61WmMOd7nGYjRdeoWbZ xkSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Du3ca64W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j4si4078503pgc.186.2019.02.14.18.31.31; Thu, 14 Feb 2019 18:31:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Du3ca64W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406053AbfBOCP6 (ORCPT + 99 others); Thu, 14 Feb 2019 21:15:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:55476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406011AbfBOCPz (ORCPT ); Thu, 14 Feb 2019 21:15:55 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1A4DF20643; Fri, 15 Feb 2019 02:15:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196954; bh=N+7iE94QtShBEuJOFIUlVhDG9iuMNWhZ1svS+hbpEA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Du3ca64WEA9gzvw+OOyyqZWyIitihPGcPpWdx/hMS66d6CTwlBz2oj0SCGTuWA5+d NG2UXfQOBaKrX8dx11CbKcpwutkmJlGf//tm7/7pscLIkbgCF/aXTVz0Hc6YS1Gja8 I+LivJjkhcx/XtSXwVcrGD9RSHEH0JF16Ytts9YY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Carpenter , Felipe Balbi , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 3.18 05/16] usb: gadget: Potential NULL dereference on allocation error Date: Thu, 14 Feb 2019 21:15:35 -0500 Message-Id: <20190215021546.179605-5-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215021546.179605-1-sashal@kernel.org> References: <20190215021546.179605-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit df28169e1538e4a8bcd8b779b043e5aa6524545c ] The source_sink_alloc_func() function is supposed to return error pointers on error. The function is called from usb_get_function() which doesn't check for NULL returns so it would result in an Oops. Of course, in the current kernel, small allocations always succeed so this doesn't affect runtime. Signed-off-by: Dan Carpenter Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/function/f_sourcesink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c index 45b41d1cfd19..ecfd9e71a0d5 100644 --- a/drivers/usb/gadget/function/f_sourcesink.c +++ b/drivers/usb/gadget/function/f_sourcesink.c @@ -1149,7 +1149,7 @@ static struct usb_function *source_sink_alloc_func( ss = kzalloc(sizeof(*ss), GFP_KERNEL); if (!ss) - return NULL; + return ERR_PTR(-ENOMEM); ss_opts = container_of(fi, struct f_ss_opts, func_inst); -- 2.19.1