Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3134713ybi; Thu, 18 Jul 2019 21:42:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAT/IBTe06DAWbdpd45NMjM6/OH6Npo5Y0kdhVeOaDZIB/vfiXAoXnOQ6xD1eOSxw1bxoj X-Received: by 2002:a63:eb06:: with SMTP id t6mr46802889pgh.107.1563511359638; Thu, 18 Jul 2019 21:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511359; cv=none; d=google.com; s=arc-20160816; b=Kl9IcVwu7NOWe+llTS+CUyf+ZydmzejZrqsPkY11Pf+eoI/SsqOpZpNPMj3OcuoNdF vflTS4A1xbQxZ/VehQbWua2qHGPqtZfiPaGdanJGnB9Px0C/DS03M690Ku7Lu7IMSvUn II2CH/E6yEiPZ5lo6SNJ39v6pPvTyFeciw+j1UBrAnt7SCiYwXHC4Kj5LhWAD3uwqqQQ GzjsCXJArQROeKKQfJl28HSMZY56N/MlldrVb0b2JGWNRGVBHl+2XLtRO2H1X8OTghj1 TuKoJ4goiIokAqjyPjVP/vo1T6gPT9hb1wGEN2ss7zCPh5Tuioeq5IegSiWD5kyluez4 BTUw== 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=ZUw5IohfuVKwcAXnEITN67DcSL6NGSsevLOaf1MP9+0=; b=LC1D66CtWDukkwbabvnREmi7SHUC0DFJsFpkb0Jq69h8Pd5NU6wlsFqSjLE5+DVS31 UX9Tydy3/VDZOnTTLx0t8HXhW1gT0DY5sOahMXfg2zhjHPJrqS4LBHi+ZTfVeQGtXemP MTG4el4Z4voiApvTPFRQ+/+vDkK2TX2Km9tqfWhJvOCjwNk/S1y7ULDy0aRpradCVLya yBobSLAMZJSO+ZQTedwIqkTiiUqu6IRsez6T/23VJRJkm9RRxEQ4vRGI+xEi59HRtvac /uJcdPLOVVYvK0ORKxbPjz0zj1LjQ9IiGGEZhyl60/vMDXkE5nbP34KzOtrtJ+Kdd+bd QGnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sNko6ULo; 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 t24si169859pgu.221.2019.07.18.21.42.24; Thu, 18 Jul 2019 21:42:39 -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=sNko6ULo; 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 S1727247AbfGSElI (ORCPT + 99 others); Fri, 19 Jul 2019 00:41:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:56396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726829AbfGSD5F (ORCPT ); Thu, 18 Jul 2019 23:57:05 -0400 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 24B0A21852; Fri, 19 Jul 2019 03:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508624; bh=X4vd8OK4yXQ0AbEdR++MYAR4NsXHtv+u2lPVXgjJSTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sNko6ULoNw/Fnl3nm9xeBX3yoVu0BVO2n+Edfo1if4GTfGXvf5BCLs1iVzuGzS1mK b4S7mUOavgp/RMYXDOkXqq7Qts9Tj2qMo3/Zo9sWSxznoSuP6kcmRfunfFjV7cL6DV 97R/hS+vYL4/Wa1uy7KzMpA6dgeGFFTomBC5HBfA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Quentin Deslandes , Greg Kroah-Hartman , Sasha Levin , devel@driverdev.osuosl.org Subject: [PATCH AUTOSEL 5.2 008/171] staging: vt6656: use meaningful error code during buffer allocation Date: Thu, 18 Jul 2019 23:53:59 -0400 Message-Id: <20190719035643.14300-8-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review 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: Quentin Deslandes [ 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