Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp576956img; Fri, 22 Mar 2019 04:23:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJLVh7p4JiABUTxTHebWZG6HUlUDxZDCKSFU4OMwni7qRZ+vCnjuRCGl+IIrddWTuSgVer X-Received: by 2002:a17:902:2848:: with SMTP id e66mr9141316plb.181.1553253836544; Fri, 22 Mar 2019 04:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253836; cv=none; d=google.com; s=arc-20160816; b=bMe70ttSMfYcP8UcnPq98uR6LO+JgfHn7tEzyXWm+UzQwYf8EW+xZrQhB8qfRSrmYG qgAiV+HpPGAjbKscdrP18nge6BjhBVNc3pQ6Sct5Dq68bevd2uWoOHgqnzeb3G2Yhfkx 9JkK8ZXtnp+0q5vl9m2wpZ8RQSXhIJ0aUNJ10O0hrar5OcWo336a/C92rM7O3QzDNrCE azkf9U21ZVf7zy2gz5htEUv17JyCAI3owDaraAPBQ+sD7xaYKc7mCp4qclijjYtXlSrO AC/rpT/rXg7rVLmJyGJ20gudOXE7JzVAtBEgMLgdKzMXUmuiX5XUx1NEA6ktYL8MSGAE SuOQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AC4mqKVIajqwX+TaRIZwqPE7nTPJqZOlDOn8YLCdT/c=; b=ul/PrWFK/xawP8cuklXyipPx+J5d3dwH7XZkO17EW/eWwjOWBmuyVqCV+zNgNWrceC 5c4Z9MkbhVgGVQA0xX1VYhsew3yFeRxOtcQWtoMTauQxxroqce3m47YVTafG/pTAGxbu Xxtv1QSKbk16cb4r9pxN1J3AxQW441fAkIz9mgpv3we0ExKeHXWjasRo0VlNg0++E59P sMwL75qzas3muUSJ095brN6mTMt9awBnJklrKcBfkFAKHlF20a24rsorlJeMyRawuvVL RRqr2dHb2/ghxUCgPLm+AGGLCKrsfOK/c+HEVqwvCVLmik3vmAReYdROQgAdtAGmZGxw VRaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IQxFQkOL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7si6578447pfb.69.2019.03.22.04.23.38; Fri, 22 Mar 2019 04:23:56 -0700 (PDT) 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=IQxFQkOL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728485AbfCVLU4 (ORCPT + 99 others); Fri, 22 Mar 2019 07:20:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:47332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727957AbfCVLUz (ORCPT ); Fri, 22 Mar 2019 07:20:55 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C2CBB21917; Fri, 22 Mar 2019 11:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253655; bh=5em/hWVJj8a/ps1CgDWg89vBP224+tMO7uguVUMSDQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IQxFQkOLi6zfIEvrsJ1jwpFA7LsMZ1JCTiZ8ARJYMhP3He4kvjR6H76QX4Jy7ukd+ tRQpSwn8qG2rfEBcshDbrjI7m7/phsL+NlKXvZeORarvVFv5ls3/V/stliqWv6nA5i E4gbk1e8kL6g0gBeO6J/eQnJSsvcrqiHjfsSygeY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Felipe Balbi , Sasha Levin Subject: [PATCH 3.18 031/134] usb: gadget: Potential NULL dereference on allocation error Date: Fri, 22 Mar 2019 12:14:04 +0100 Message-Id: <20190322111212.005243655@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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 45b41d1cfd19d..ecfd9e71a0d50 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