Received: by 10.213.65.68 with SMTP id h4csp245600imn; Fri, 23 Mar 2018 03:49:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELtWoU/yRkfz97qwgIOfEjfn/ULuDEXv1a78i7FWXOspes3J7TPYLgiQUx1fPjWFNkt360wm X-Received: by 10.99.105.202 with SMTP id e193mr20032142pgc.84.1521802182477; Fri, 23 Mar 2018 03:49:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521802182; cv=none; d=google.com; s=arc-20160816; b=xq+ggeQ2XiNcA3pycpARk/tu3+cQPcAyDo7Nin6eu5LQlB9O9iMn40AIPuaWaSGvpk 11epaa0eHCF8BtussvRt+iLFxSiTm4N+SacgXgtyd8+AoPkrMGicXzcFIukaKf4V0Uge JJ44B7t4M1jPFISNOmfSlJyAaDtXN9JlLbmeI47Bv3Rwwo6lifI4JL8LYw/mAMn8VUt7 3/cIuARm0uN1V7TTTUy91hW/5cYraVoc2w9RyhPDUQxYkPr5j/bHMyX4j+nbqDR2XX8m 0ZqTWzSvbpKKlOmkBQ3iNl4b6j52/qYN1E3GqU+LyDNezGwxp5N3wdk/tFqkRyubLO5U QwKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vFv+vRNin3orJNTgpMWyO2/7TbyDubiVxjRRxvnw9Ek=; b=ycjLutsByEd818gzbnb3/En9QXWSkvBMat5I3H55PtMrPWgKvwULd4vZaTjplZGxlH I7iPrKGGVymnJbklmhV2nLKVM43TtpbVNi+xHVA5ZsENxA0ikTKJiZyIFKBrRROOyetw W/3+/XkqQo5eleKyTim0E+OnvvqaJD+XLbhtiqqOj3I+CpOmLJrfRm4nTra6Yqzxd7bI dboiBXBy0/9bJIRCaVj+Rp4zQpOIwFlgCbmLx2lvZ2RhE7y8tP12vmxDZYgYLcO1TFrw YHmMNsnyIQ9sosqWBA8qoLiNky7SluDRiOodwrGqBuqYfJmHV2BODFfW1I8lisfrXgvd vX9Q== ARC-Authentication-Results: i=1; mx.google.com; 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 l62si1446505pga.144.2018.03.23.03.49.28; Fri, 23 Mar 2018 03:49:42 -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; 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 S1752477AbeCWKsh (ORCPT + 99 others); Fri, 23 Mar 2018 06:48:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45412 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756023AbeCWKOy (ORCPT ); Fri, 23 Mar 2018 06:14:54 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 247061260; Fri, 23 Mar 2018 10:14:53 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Jakub Kicinski , Kalle Valo , Sasha Levin Subject: [PATCH 4.4 47/97] mt7601u: check return value of alloc_skb Date: Fri, 23 Mar 2018 10:54:34 +0100 Message-Id: <20180323094200.258964491@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094157.535925724@linuxfoundation.org> References: <20180323094157.535925724@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pan Bian [ Upstream commit 5fb01e91daf84ad1e50edfcf63116ecbe31e7ba7 ] Function alloc_skb() will return a NULL pointer if there is no enough memory. However, in function mt7601u_mcu_msg_alloc(), its return value is not validated before it is used. This patch fixes it. Signed-off-by: Pan Bian Acked-by: Jakub Kicinski Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/mediatek/mt7601u/mcu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/mediatek/mt7601u/mcu.c +++ b/drivers/net/wireless/mediatek/mt7601u/mcu.c @@ -66,8 +66,10 @@ mt7601u_mcu_msg_alloc(struct mt7601u_dev WARN_ON(len % 4); /* if length is not divisible by 4 we need to pad */ skb = alloc_skb(len + MT_DMA_HDR_LEN + 4, GFP_KERNEL); - skb_reserve(skb, MT_DMA_HDR_LEN); - memcpy(skb_put(skb, len), data, len); + if (skb) { + skb_reserve(skb, MT_DMA_HDR_LEN); + memcpy(skb_put(skb, len), data, len); + } return skb; } @@ -170,6 +172,8 @@ static int mt7601u_mcu_function_select(s }; skb = mt7601u_mcu_msg_alloc(dev, &msg, sizeof(msg)); + if (!skb) + return -ENOMEM; return mt7601u_mcu_msg_send(dev, skb, CMD_FUN_SET_OP, func == 5); } @@ -205,6 +209,8 @@ mt7601u_mcu_calibrate(struct mt7601u_dev }; skb = mt7601u_mcu_msg_alloc(dev, &msg, sizeof(msg)); + if (!skb) + return -ENOMEM; return mt7601u_mcu_msg_send(dev, skb, CMD_CALIBRATION_OP, true); }