Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp198397imj; Thu, 14 Feb 2019 18:30:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IYD+dCbDaY9VrUE7Rcsise5qJP8EmlRNNb9zWF8JHhIqdxD6P1ZzOdUQStuX6e1N8bNBdg7 X-Received: by 2002:a65:5c4b:: with SMTP id v11mr3057384pgr.333.1550197824931; Thu, 14 Feb 2019 18:30:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197824; cv=none; d=google.com; s=arc-20160816; b=QwtwzyXmCpNzpqIFSI45Ry8mYxjojzxHKFzfKDtIIi6z4sApoGRrKQCpUBRBK1aNYh 8EVK2t8HabvMJ9KXcL2kjiRpaRt0higEXkAK9E+t6HYPKgcNNGHZJu07JAwhlgmoWMpN l3LbKWPUaq32ICTvGW92st/2U4SyFWzmCTheE/xcvmo/iaRPrT8DyKMcs47zIf6HFlIr rFZemStUAWOyRw2KX6McVQO3CW4FQNTS/CGmhX+znUgzOAn19eTUHbTX/sTwMlwY/sAM W0y+6XPdRR2ESyv9E8ushLCx1mqb7xxTnpSoXBIPbw+WeP0BJJHPj/3alnV4MJBmKBe+ X7bQ== 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=BdwSroIlrOmzYQpUfUTakPZSITlAGIjeK/3bYgPg5DY=; b=wj2zFjap88cZiqRK+yUSDsQAc/pqL69C0l5fc5HjvwDiQd0tLzj0SzH3NzhU6RLN0N 5MMlgL7wBtXJcuXq7klZFTWStOzH3u8D6NKKCa/JI4DBzPN7HcF2PiFuy+KC+uE1oPzc A11doSlpDdWECnwqbdmxbSZgwhI6aNIvpainfzQDs1aACPFUXkOy+RB67vl6mcsFv9z3 rSZgNbJKklCsBDj6mYYXoDnnt0W2SiTojqbG1dWAxnX8XjXPsk5brEDs89IdnEzJFLeo p0nsYmt0w8xen9K44CZk+HH0IYzhBrrVydLcxJSHDZT4UlgcWUBBKV4hu/IRlKYBilLO 9Uww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LEV3Tiia; 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 t71si3996641pfa.244.2019.02.14.18.30.08; Thu, 14 Feb 2019 18:30:24 -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=LEV3Tiia; 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 S1731764AbfBOCJ2 (ORCPT + 99 others); Thu, 14 Feb 2019 21:09:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:49516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731685AbfBOCJS (ORCPT ); Thu, 14 Feb 2019 21:09:18 -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 5E5CD206BA; Fri, 15 Feb 2019 02:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196558; bh=DPzk3bfpQ4QxcFB5vcNaOzyaV40b44hCAKC+He+PL/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LEV3TiiawIyBfAJivKGGDVjqDw+ppb40XSHbmpSNuqslb+vrxIqzUJmrMuShzlaaH 4qDFa3/jiXz0EJYtBLp7kqRe5ngjdMe7GqScl12p2F8lLwLc07n9raKbrFdMwrKeGS PEmI1KBSXPE5t8yqp0Ncp1nGsXCzYOktzZkj2Y/g= 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 4.20 14/77] usb: gadget: Potential NULL dereference on allocation error Date: Thu, 14 Feb 2019 21:07:52 -0500 Message-Id: <20190215020855.176727-14-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215020855.176727-1-sashal@kernel.org> References: <20190215020855.176727-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 9cdef108fb1b..ed68a4860b7d 100644 --- a/drivers/usb/gadget/function/f_sourcesink.c +++ b/drivers/usb/gadget/function/f_sourcesink.c @@ -838,7 +838,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