Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3650114imm; Sun, 10 Jun 2018 22:27:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL3bvIwreu80OzItHG8aVlQsYlutAzhvGYBbi1KSm1z/jETYB9hCJ1FyiQvr2WOqZl09BnI X-Received: by 2002:a62:d09:: with SMTP id v9-v6mr15827559pfi.163.1528694857005; Sun, 10 Jun 2018 22:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528694856; cv=none; d=google.com; s=arc-20160816; b=uKWkj5hzA1kFtuazxwx0abqRPOnTIOck65Sr9i02QF4SkqoH21Ff84o5aLV151WX+H PNI21QFE5GBf7cnEkxR6arUziUe0M+YHxsJYLMapr6YC3eUCnMAFlFU93lscv3exNQ4g Th48fKJJYUIbRFg1sxEA6a8aL2WyGPZ4LpMFlHn1tMHp0MxjVe28rSsXXdIh6JtYQiG1 W7UoRBmIOKH+ZPuKSBzoD2zzwgVPULk9otaaoLUf7IsEhAKyhVVgw76/TAULuC+sHau3 Dmn3zcZHtm12Bkbm7x+3IWk7kClat+VZf4l97RfDyyXmzs6E0pqxn6pC0MiQWHQagC9L MTTQ== 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=h1C0XpA1CA0aMQwbiP00P8drmN+/awCRYrM820R6Y90=; b=QPegjNqygijrbyJqG/fRQP7aM9HA5dp6xtcgtRUVEHPwZ9W4f5NaXKf1fKj3RJa1Bb FqMzrTcAiC0H35Xr3oeBX4sJu6URFrNzkaY7QxDq8SJpwLvlUSOQNPDtXSLcQQ3E20Ue mVnOsZIN46Hie5JsMZF0AbkiCWq/ti4D0Tem8bwHdjzkQxPFaACwWa6Is9K/9r0t65FW r9bRZZG8N+gXhAmnTo4fVs0BF5qoD3nBupVpS5w+vWUYQn00ponKpTn9Ng4fN1/K7vBj tG3k7zSAkCBTA94Q8+o0PzdFZe1vBJBLfCSiCu1RGSECjnOBcqEtg4lzp8R0peMDVMNH r4SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=sIPKuqdr; 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 q13-v6si23885037plr.220.2018.06.10.22.27.22; Sun, 10 Jun 2018 22:27:36 -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=sIPKuqdr; 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 S932375AbeFKF06 (ORCPT + 99 others); Mon, 11 Jun 2018 01:26:58 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:38773 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932272AbeFKF0y (ORCPT ); Mon, 11 Jun 2018 01:26:54 -0400 Received: by mail-pg0-f65.google.com with SMTP id c9-v6so9177194pgf.5; Sun, 10 Jun 2018 22:26:54 -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=h1C0XpA1CA0aMQwbiP00P8drmN+/awCRYrM820R6Y90=; b=sIPKuqdrJEbCe6b71m/VMv/8F22ucUV+cVmKOQMO4lG3Gi2Ueh6MidKs1y/GC0lgPH YlSN3Kpee+mM+o5Urti94S+97UjkPAlvape3A3qIEqprQNlX4OFJEdzmO6WnZU78UrWn 45l5IvKsDanXhFhPe3Tb9y2DH/5ZxuEyETWyjxOvJ7+xfl239YqQp5N0hh8h2S9KQyEZ yzq0uYexKc12HP1FUWHfy/PWObRb2xm6koaAI1puzMfMnHLS1dwIOM/VTLmQnce9CXZF pYvaj5ogB9vun8SMIl2CysIoIeax2ulZXVhlmkkYCgwvIwxJ/I8758sFFHcITLcsXTXJ e6kw== 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=h1C0XpA1CA0aMQwbiP00P8drmN+/awCRYrM820R6Y90=; b=IjCp+PB9I6TFsVHojHPjhwGYhnpofeOX//KL2yf5BVl5itwzO5sXY92LGx26E2fmfp GE5zES+HI+AHPTr255tiQUTyW0o1eb2kSgBTLUJlWAt4x1vTpp2/ntKaMKwdE04fI7Kc PRJ3OaQxkI7Y8Ciqvu1yfGQj+f0uC1MCb/75ORx9iTqO7clVa6iSHReFCoPtUspSkuBI PNKT3MISSjpgFNn+Sr9eH5TtYegsBk8SU0Vwkkefy1pcKemBflLH55DAOTrmYjvTIEzG vro/6313PloAGbafCxNBjcfYXIEFClIPZCSrrgrkETqj1TUZ735CZDryjCUwwJPzRT0q g29w== X-Gm-Message-State: APt69E3kFH56mhnmNI7u39bdStXQX6kaJLd3pOeuMhIqNihGlv5ZYM0D ebp1s8klq5Q4/oNpIaKlBZgJPwxWMgk= X-Received: by 2002:a62:9385:: with SMTP id r5-v6mr15997959pfk.59.1528694814270; Sun, 10 Jun 2018 22:26:54 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id p12-v6sm22608383pfi.175.2018.06.10.22.26.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jun 2018 22:26:53 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: dsa: add error handling for pskb_trim_rcsum Date: Mon, 11 Jun 2018 13:26:35 +0800 Message-Id: <1528694795-32000-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 pskb_trim_rcsum fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling pskb_trim_rcsum. Signed-off-by: Zhouyang Jia --- net/dsa/tag_trailer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c index 7d20e1f..56197f0 100644 --- a/net/dsa/tag_trailer.c +++ b/net/dsa/tag_trailer.c @@ -75,7 +75,8 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev, if (!skb->dev) return NULL; - pskb_trim_rcsum(skb, skb->len - 4); + if (pskb_trim_rcsum(skb, skb->len - 4)) + return NULL; return skb; } -- 2.7.4