From patchwork Tue Mar 19 03:19:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Pakki X-Patchwork-Id: 10858773 X-Patchwork-Delegate: sameo@linux.intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5CDBC1708 for ; Tue, 19 Mar 2019 03:20:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F584293ED for ; Tue, 19 Mar 2019 03:20:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D5912944B; Tue, 19 Mar 2019 03:20:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4D95293ED for ; Tue, 19 Mar 2019 03:19:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727146AbfCSDTu (ORCPT ); Mon, 18 Mar 2019 23:19:50 -0400 Received: from mta-p7.oit.umn.edu ([134.84.196.207]:46734 "EHLO mta-p7.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726579AbfCSDTu (ORCPT ); Mon, 18 Mar 2019 23:19:50 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id D6FE7B45 for ; Tue, 19 Mar 2019 03:19:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NTfpJi6O0JwS for ; Mon, 18 Mar 2019 22:19:48 -0500 (CDT) Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id A7631994 for ; Mon, 18 Mar 2019 22:19:48 -0500 (CDT) Received: by mail-io1-f69.google.com with SMTP id k24so14996678ioa.18 for ; Mon, 18 Mar 2019 20:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=fHMSauccrIJ9HihNDOavw9LAVGK09QKXxKSO/H0MbjE=; b=nnVtm/8MN7bK1K66rhuZ624aJBIK8T50Z2c/ARXOugIpTiH6hl+Z87hhFe5Ak0l0DI fbBhh7o18k3HQ80Rv87c+OIxwHB1I+yL6sJ/khrCB302jQREZBN/gSibY8vMUtsN4U7w FfMSo9m28zmzzyGl2CSSLX5SitSDbRQLxruAsuO3Ro44HlXUhoZ/zuzrf3Nc+vsjxlFy x8YZXCjb2cSyaMOoGV8t1WjNKJsAwfnSaLFITDwhMkCNC08b03doZXoUyve1Wx7qmB1h P3+wKpzDDwO11QbkrRSzHjUIWfxiZ2d+JxlG94mI7kavc09LHeSUei7Osh3wCT7mZ42u gqpw== 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=fHMSauccrIJ9HihNDOavw9LAVGK09QKXxKSO/H0MbjE=; b=IvUmI4gun8GmY4/qtBcHz3+lgNzmjiI3sxZX9gq7cwUxqscjIHruuqkd+DsH27O435 QqyfwznqJEh7TkpIdxcXcGUae91LvYNFPdzautI7SV8DFNxq3V0+vtprovKVg/m3OwaO 2SmfV6QKXsCsfeoxW3ghRYGNHjaI5Tp3DfEwMZPEs8JsOXLvIgLYP3rC+46GOQpYy6gL 5rWodZjfZNhAauCuY6IxaYv5KqxhA78kUWq8hKk/EjCvalYdHUkC/mL2+Qs68lc3jV1/ 7ZTVTS0wgueaC6+z3lF1tCMK9cdnoSSxghTgMx8KiyUP3Qji6mj3ur9DAi17RTwMq3gU R2rg== X-Gm-Message-State: APjAAAUB726e51g/UDHWae1TfZ7vSn2O2iotsAN3tgPXFBY2aBCX59Xe xfe3HPEvz7er1buO1HC1dzcZh0ROIXYojLhvWODwyvIPzTjOy01Aj9iSLVE3dzZtR6KFP9yrleK QZ2Lx1qb+Kl5FPwH/qwzHGXXM0dUmWmg= X-Received: by 2002:a02:b703:: with SMTP id g3mr137942jam.106.1552965588332; Mon, 18 Mar 2019 20:19:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzeoP/kvrNPPv201hX0xDPECjhwxZLnNlLFv8wbsnFiAV5IMiJ8QiU35yw/YyQCLM2CyVLyA== X-Received: by 2002:a02:b703:: with SMTP id g3mr137934jam.106.1552965588156; Mon, 18 Mar 2019 20:19:48 -0700 (PDT) Received: from lenovo-1.hsd1.mn.comcast.net (c-73-242-25-233.hsd1.mn.comcast.net. [73.242.25.233]) by smtp.googlemail.com with ESMTPSA id 202sm940459itl.1.2019.03.18.20.19.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2019 20:19:47 -0700 (PDT) From: Aditya Pakki To: pakki001@umn.edu Cc: kjlu@umn.edu, Samuel Ortiz , "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: Fix to check for kmemdup failure Date: Mon, 18 Mar 2019 22:19:44 -0500 Message-Id: <20190319031944.18984-1-pakki001@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of kmemdup failure while setting the service name the patch returns -ENOMEM upstream for processing. Signed-off-by: Aditya Pakki --- net/nfc/llcp_sock.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c index ae296273ce3d..17dcd0b5eb32 100644 --- a/net/nfc/llcp_sock.c +++ b/net/nfc/llcp_sock.c @@ -726,6 +726,10 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, llcp_sock->service_name = kmemdup(addr->service_name, llcp_sock->service_name_len, GFP_KERNEL); + if (!llcp_sock->service_name) { + ret = -ENOMEM; + goto sock_llcp_release; + } nfc_llcp_sock_link(&local->connecting_sockets, sk); @@ -745,10 +749,11 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, return ret; sock_unlink: - nfc_llcp_put_ssap(local, llcp_sock->ssap); - nfc_llcp_sock_unlink(&local->connecting_sockets, sk); +sock_llcp_release: + nfc_llcp_put_ssap(local, llcp_sock->ssap); + put_dev: nfc_put_device(dev);