Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4875104imm; Mon, 11 Jun 2018 21:42:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIOvmblUa9McUaKJmswXt8sHc6FrQLD3DG7h+Mf6s7+MEF1sORKVZFhGFf0Ea1lwg3ScE63 X-Received: by 2002:a17:902:4101:: with SMTP id e1-v6mr2250040pld.205.1528778564612; Mon, 11 Jun 2018 21:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528778564; cv=none; d=google.com; s=arc-20160816; b=Vo44wb0lVafIuky5ARz/2+iY31IQJPXckiuXBrQ+Amq4bxAn5+LN1vYcRK7lwA4ig4 M3+1EhKVhWENaTdI0z0vemIwyVSkNeEFUxuHmSMzrD10B4AP8XsRp7x6wSiVeKjFfCZ0 Oi6PwWIvclOlYS1MvuN0n59zsE+cFnhMcc4lB1avdeAHEyePejGeHTcu6QDEzradvE8Q e0dfIO8fpxzDgx60z5ZLH0RemW6WV1uzzfrTWcp8eHDE88btkluFVwMFUd7+vgnxOOB0 rCJjHBZ3z3wz2X3H/7hs00Y3JO5E5ZgAJbfTeLKl4lcA/D0UAoCjRqiABiR9IQU8/Zw2 8j5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=f4m7qOyaTR8jMyJ06iiLVjF3E3BsAYkyrEs4pmCan1U=; b=lWglAY5+nl07ehf64TsDUXYNg+EqjPVb9U/y9R4CcVBZ2s/uYv5bVvtszi8pFF/IQl dGaL5scJDUgDje3ckgtNhnXrQQ6ji0z+p5R/rJy38nFek4O//vWOXPnqg5P+dme+p4gA 2ecoksj5n/IwQQLqGxdwYaeGI/EGFjXoEL4dY58DqpAdtZ69M0FiEQlypPRxnm1zGM7K /dL2z4ZHULoxRARXJ5TmD+yViiFb2kgntN77fBbGMDSwLdgeRr4WjWE0m1xM8l5kOpYZ EQbOdZGZ80xqhONHH0mpoWO45aK7zZ/8W/rn+sh3E8Pn217d5B+NQBDyOshFCFmxXsoC yQ5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=nTiZw4UQ; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b19-v6si26374349pge.666.2018.06.11.21.42.30; Mon, 11 Jun 2018 21:42:44 -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=fail header.i=@gmail.com header.s=20161025 header.b=nTiZw4UQ; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933110AbeFLEly (ORCPT + 99 others); Tue, 12 Jun 2018 00:41:54 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:33474 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933032AbeFLElu (ORCPT ); Tue, 12 Jun 2018 00:41:50 -0400 Received: by mail-pl0-f66.google.com with SMTP id n10-v6so13617150plp.0; Mon, 11 Jun 2018 21:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=f4m7qOyaTR8jMyJ06iiLVjF3E3BsAYkyrEs4pmCan1U=; b=nTiZw4UQwL+3kBUopBe2mFsbm3W4+noSqpnXI8H1PfPeTxYxgChk+2qjgoSx4eqrac FQUsd7yI/t7/b/2YVOY9DCFADz2IUOwugccMPUQ9Hz8SxTT6OV3U7TL/LpeuRl4k30tN nTbXsHSSHHVuyypTlKlW6JjdtiFZyshvfy035WU0tPX6UBkdZaB2U6SwAcz5WGO0w1ee 28Z7c9+u88k6HAY+wgEarEkdHDkPhAvgD2WqsEIaZaDhtPyInj2ArPRZeJLx43LTMTFt IycZVT+CYDWYZDhWXXVOdiW4vxFO41ppSSSVjqP45wkjuUfEgcGJ3B5BYOuLeqtDFdWg SCuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=f4m7qOyaTR8jMyJ06iiLVjF3E3BsAYkyrEs4pmCan1U=; b=q0gaUO/zCfSDlS9U6SZorFgi5nk3JO6uKBNvQ3oDVriRV3onFdhBTwBba3MHy244tC yYhVack4Z2BHDrfBUrr9r7D/nry/EaPMNcX+bwXHK7o7CnUUk4fKhfJi3CmnEY9zRYC5 VnVyE9tu4W1DYdLPv6FgPf+UiUacLQq02R6B1/TBvnNo3W/H65TWR/0DOeLBXgHYFtPP 6qVtBpmQrCrgD+igG9l5JVQNyUXheG2JFeeSoGvhVYHRimydWzURp5A2Gpt3KYX+RHXP LnYcgz/9nLSczk4I8njeLsCdnAwNmssvkxntAPoQgBTF1rLJmyOVStMj9OkLkqTkWbif zu0w== X-Gm-Message-State: APt69E1jO8k7A5a/o2q3zZZSaIL9Auf0R3JjfIUEpvOHwoHxtBtQxtu/ BK75lYfnNq/kZZCWhjurdoY= X-Received: by 2002:a17:902:1023:: with SMTP id b32-v6mr2287037pla.145.1528778509759; Mon, 11 Jun 2018 21:41:49 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id c12-v6sm41445781pfi.177.2018.06.11.21.41.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 21:41:49 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Felipe Balbi , Greg Kroah-Hartman , Bhumika Goyal , Johan Hovold , Andrew Gabbasov , David Lechner , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: gadget: add error handling for skb_realloc_headroom Date: Tue, 12 Jun 2018 12:41:41 +0800 Message-Id: <1528778503-41615-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When skb_realloc_headroom fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling skb_realloc_headroom. Signed-off-by: Zhouyang Jia --- drivers/usb/gadget/function/f_rndis.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c index d48df36..17c164b 100644 --- a/drivers/usb/gadget/function/f_rndis.c +++ b/drivers/usb/gadget/function/f_rndis.c @@ -374,6 +374,9 @@ static struct sk_buff *rndis_add_header(struct gether *port, return NULL; skb2 = skb_realloc_headroom(skb, sizeof(struct rndis_packet_msg_type)); + if (!skb2) + return NULL; + rndis_add_hdr(skb2); dev_kfree_skb(skb); -- 2.7.4