Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1822053imm; Thu, 14 Jun 2018 04:32:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLdYM7ZTZksJ/j94SObFYAoU8FGtGM6S1pyPtCCa45d7Cl5rCXF+K9p0aUA46Q9EMZgKOo7 X-Received: by 2002:a17:902:8604:: with SMTP id f4-v6mr2600058plo.4.1528975958237; Thu, 14 Jun 2018 04:32:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528975958; cv=none; d=google.com; s=arc-20160816; b=VOJTgYBupv9IUo9nx0hrxnsyYVYJXzzANgx9RqsVO1aftjXO7+Wwjm46EPqypF97nQ QcZQ+ICIQStpcdW7rIy7qoZZSdHyGtfusV6d35Y0CPiYaibd5LDsluXf3AAwdoQ8KC8N NnIGFi5wkygmNGzG8pY/rn4Jtf7YHwKIIHO2x+kZswk3DCAHlWnE8WxaAAX8LveTjbXF K5bNpywHmplLjJdflGdFgJ1FvnDEUKX1Ij4U3ZXnUnlcrzActZN5TKBJdZANlUq7cAw1 jDoyS24YH+Jolub4SUupEt1XMDZ89OyGZVYkmaq2oI2WyWDlXKONHagboBUiKLTwfhJk NKcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature:arc-authentication-results; bh=YDAAbse4iQFoVFB9gB6KAuHl5DfgzcuZxYfVl4UlGPU=; b=IzzwWwV3cYv4ApexSFDrEQ1epUWnqh8NY4rMK7pjLVC+4ZbcoIWOxHMHMdc6GaOKlM 0JvV5agDbx4EAV8W8TgGqLPv9v71M8dWuGMNBJHjYSYEXcfUWNjOFonMHr+vieGCEDZU UrgHbNYAXVpskIqQMhboOxOd3TEKKRriuCfxjM6QJqalPi/UlhX7XiMGzMdj/APdgtN5 0+XhXoshlXkvIHqBW13QqBeicaKr5JLqGLcnckyxLweDDNLIapkGFZXGp+4BCcVbCha/ RX7PdNm19BHWYAj04Rn/9/dvnLB+9R+Qmivu8DUgYW6wAsie4Jb0o3gp4VUNhI6korEo XfVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=pbhfCiES; 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 z2-v6si4332050pgn.193.2018.06.14.04.32.23; Thu, 14 Jun 2018 04:32:38 -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=pbhfCiES; 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 S1755096AbeFNLb7 (ORCPT + 99 others); Thu, 14 Jun 2018 07:31:59 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:42600 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755042AbeFNLb6 (ORCPT ); Thu, 14 Jun 2018 07:31:58 -0400 Received: by mail-pl0-f65.google.com with SMTP id w17-v6so3394384pll.9 for ; Thu, 14 Jun 2018 04:31:57 -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:in-reply-to:references; bh=YDAAbse4iQFoVFB9gB6KAuHl5DfgzcuZxYfVl4UlGPU=; b=pbhfCiES8sTPilxPUZ+ZwKWK7qVI8Uhl1G8iEYe4RxtWIa6oq3idKNxTJ4gMQgO6Tu isTe82hZRQW+JwUU1iG1oKo0r2379JunUlkZBADsm5KsgYpDCdAB5ofBpzSrlQ4UAQDN 117AA7LW/y271yoZWQH7Dy84N0rBp4viyP0BaX6Rp1n96sN7ddFjeMAd606t6gndEuim N2Y/O2NTLdhnFbvuuR8Gnt33U/EG+IAcj/eQN4EhjMbIGTxVOcf/2kpmiaC2WDnnvxfR TEu9Wlna2dsCKVuj5S/rRDDF9Sirlsj0KougUEenuDnCGloTABPOC5m3P185IV9zrDjl xo2Q== 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:in-reply-to :references; bh=YDAAbse4iQFoVFB9gB6KAuHl5DfgzcuZxYfVl4UlGPU=; b=Fb/Gb8jInx2p4fnlDH3hwDYWifrASmjnUVTm5OAV3Ea4cjo7AzlucbWxc5FFgP/GuA 49H6TThQ5v8hIWA/B1h/HW+W0IwwZEg7Ov7CMp2wy0EV693L0aLkrexohXNPmBk2HZWQ 9N7JWkEMFWFIVeuUvJpkSNeBGlWJYH+i9sOuxJTefLaMwf5+lpWz/ecpcYxb+LHRdrQh dRb4cEifhAHzubwQgNoIKTaE+ebyAQ8/8vTOPsvjMnNKPeBaEE0HpyKvJ2pkf2fSN9Gm 0+fh37BCc6pC0SekyWsO6gFk5T3DFsMKBXBvQhv8dYy8Yp096x3T/TfqPAC7ZXiKHPJv IIcg== X-Gm-Message-State: APt69E3r0NQwFN/PC/ZG7xOoW8Xe1dyWgO5t7JTkFcc4kHv762HHYlWg MYxclRvATGjk8oxiKX/vuH2nVCYB+sg= X-Received: by 2002:a17:902:4101:: with SMTP id e1-v6mr2607180pld.205.1528975917661; Thu, 14 Jun 2018 04:31:57 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id s75-v6sm13052683pfj.125.2018.06.14.04.31.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jun 2018 04:31:57 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] staging: gdm724x: add error handling for nlmsg_put Date: Thu, 14 Jun 2018 19:31:51 +0800 Message-Id: <1528975913-51879-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528693766-31570-1-git-send-email-jiazhouyang09@gmail.com> References: <1528693766-31570-1-git-send-email-jiazhouyang09@gmail.com> 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 nlmsg_put fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling nlmsg_put. Signed-off-by: Zhouyang Jia --- v1->v2: - Add some cleanup --- drivers/staging/gdm724x/netlink_k.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/gdm724x/netlink_k.c b/drivers/staging/gdm724x/netlink_k.c index abe2425..16da03b 100644 --- a/drivers/staging/gdm724x/netlink_k.c +++ b/drivers/staging/gdm724x/netlink_k.c @@ -119,6 +119,11 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len) seq++; nlh = nlmsg_put(skb, 0, seq, type, len, 0); + if (!nlh) { + kfree_skb(skb); + return -EMSGSIZE; + } + memcpy(NLMSG_DATA(nlh), msg, len); NETLINK_CB(skb).portid = 0; NETLINK_CB(skb).dst_group = 0; -- 2.7.4