Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3811855ybi; Mon, 29 Jul 2019 13:06:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjnnFStY9WjOOWE/wma5M2Ak+PHSLziz9+xfGzSwgoCKGNUUz6t9gxae7JQ/mrBkZ3pKjW X-Received: by 2002:a62:6:: with SMTP id 6mr37533810pfa.159.1564430774927; Mon, 29 Jul 2019 13:06:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430774; cv=none; d=google.com; s=arc-20160816; b=Am+5LD9zAHAO7dRsm02q2o4zWeBm7On0vRTe7wVTqmk7K/oK1c/Zo0LdqBh7zHuDz+ cVaUrFXQS5hUxylOXqG36vPcslKQg6TsZ8M4j5xwHSEOtGm0ZZl7mk46AiJhfRMReJ9I m18mv5fQ9WEdYHaCqYB+cQhvgzp+4ZGkluMs4LnqvGxsZTWPA+4C0bIhXXl+HU/5l3Hs l2ZIGN6b7HBbMBtZueKA4l1RkS+rgt8yyrUGSpLQTUPfvwMuaydkB9JaVExmGm1Si22Z pcNxIm6oZyly66EAXmLRXg3V0+IgxQseWmVMCSJafmL15CblhF5GrQvv8XtP/k0ngxXj vZjA== 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=MzEheDGIlhwuOxZgo5hOY+xe/+gqBL24Ittjk7PaBVs=; b=0VQ3GedobjHiLjFSi3yuh2ZqB8gW5gjnZmF5/fwWyaEy9Ni2MgcPftfd/r8+2G8eHH 8viikXaQXMdckaFlRJ7dz/jWM4CofAbEvuhnx6OidxQaTfEQEyYGf+jI80i9MY6wNhji qQepFS/g6ou+9UFYah4KoDtbtqcl5TerRZTws6vRMuXyeznvVpbgthm/29Nz6Y91VwzZ 1UCuMRuUk7TXd3w8ONnGbizWyuF2WMVE+L/FGI3S4AOygaoeeL/WDLwvMCXJ29oa++t0 sm+mkHnqBnygyX58aK6G17FofAwkNwankemA5CiGBOKo7En3XbcGMSRy0Z3vJyWJHHiR pbQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lrUCE8p7; 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 m68si31998840pfb.75.2019.07.29.13.05.59; Mon, 29 Jul 2019 13:06:14 -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=lrUCE8p7; 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 S2389953AbfG2TpZ (ORCPT + 99 others); Mon, 29 Jul 2019 15:45:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:34262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389292AbfG2TpV (ORCPT ); Mon, 29 Jul 2019 15:45:21 -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 54FDA2171F; Mon, 29 Jul 2019 19:45:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429520; bh=f7tBDxzUivvdbQFNLAvWicQS27YxUC57cCcTbYDlg+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lrUCE8p76KDszrfRbWrsEGMIc7SHPbkmJLJ8PHUtTzy+zpdDrm1yqleAOXSjvVvyK ga5WRraf4weCUiy2FY7Uh+Fr/2qG5DT9BrSU0+bnH5aqFQN8GuRDHthhsWQuQgJDQE 53CmGOblAQ8OyPaKe7mX/HD6p5JuYrCkzNg0ExBU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Quentin Deslandes , Sasha Levin Subject: [PATCH 5.2 011/215] staging: vt6656: use meaningful error code during buffer allocation Date: Mon, 29 Jul 2019 21:20:07 +0200 Message-Id: <20190729190741.507584655@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit d8c2869300ab5f7a19bf6f5a04fe473c5c9887e3 ] Check on called function's returned value for error and return 0 on success or a negative errno value on error instead of a boolean value. Signed-off-by: Quentin Deslandes Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/vt6656/main_usb.c | 42 ++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index ccafcc2c87ac..70433f756d8e 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -402,16 +402,19 @@ static void vnt_free_int_bufs(struct vnt_private *priv) kfree(priv->int_buf.data_buf); } -static bool vnt_alloc_bufs(struct vnt_private *priv) +static int vnt_alloc_bufs(struct vnt_private *priv) { + int ret = 0; struct vnt_usb_send_context *tx_context; struct vnt_rcb *rcb; int ii; for (ii = 0; ii < priv->num_tx_context; ii++) { tx_context = kmalloc(sizeof(*tx_context), GFP_KERNEL); - if (!tx_context) + if (!tx_context) { + ret = -ENOMEM; goto free_tx; + } priv->tx_context[ii] = tx_context; tx_context->priv = priv; @@ -419,16 +422,20 @@ static bool vnt_alloc_bufs(struct vnt_private *priv) /* allocate URBs */ tx_context->urb = usb_alloc_urb(0, GFP_KERNEL); - if (!tx_context->urb) + if (!tx_context->urb) { + ret = -ENOMEM; goto free_tx; + } tx_context->in_use = false; } for (ii = 0; ii < priv->num_rcb; ii++) { priv->rcb[ii] = kzalloc(sizeof(*priv->rcb[ii]), GFP_KERNEL); - if (!priv->rcb[ii]) + if (!priv->rcb[ii]) { + ret = -ENOMEM; goto free_rx_tx; + } rcb = priv->rcb[ii]; @@ -436,39 +443,46 @@ static bool vnt_alloc_bufs(struct vnt_private *priv) /* allocate URBs */ rcb->urb = usb_alloc_urb(0, GFP_KERNEL); - if (!rcb->urb) + if (!rcb->urb) { + ret = -ENOMEM; goto free_rx_tx; + } rcb->skb = dev_alloc_skb(priv->rx_buf_sz); - if (!rcb->skb) + if (!rcb->skb) { + ret = -ENOMEM; goto free_rx_tx; + } rcb->in_use = false; /* submit rx urb */ - if (vnt_submit_rx_urb(priv, rcb)) + ret = vnt_submit_rx_urb(priv, rcb); + if (ret) goto free_rx_tx; } priv->interrupt_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!priv->interrupt_urb) + if (!priv->interrupt_urb) { + ret = -ENOMEM; goto free_rx_tx; + } priv->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL); if (!priv->int_buf.data_buf) { - usb_free_urb(priv->interrupt_urb); - goto free_rx_tx; + ret = -ENOMEM; + goto free_rx_tx_urb; } - return true; + return 0; +free_rx_tx_urb: + usb_free_urb(priv->interrupt_urb); free_rx_tx: vnt_free_rx_bufs(priv); - free_tx: vnt_free_tx_bufs(priv); - - return false; + return ret; } static void vnt_tx_80211(struct ieee80211_hw *hw, -- 2.20.1