From patchwork Sun Jul 9 11:08:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 785904 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3x55KW5w78z9s2s for ; Sun, 9 Jul 2017 21:12:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hIb2Mgpa"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752088AbdGILKA (ORCPT ); Sun, 9 Jul 2017 07:10:00 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:33224 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751786AbdGILJ6 (ORCPT ); Sun, 9 Jul 2017 07:09:58 -0400 Received: by mail-lf0-f41.google.com with SMTP id z78so44698639lff.0; Sun, 09 Jul 2017 04:09:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=CMWvSt5Q2jBoO7ca23RpRfwe7cVE/fnFMb1AA89JFEc=; b=hIb2Mgpa7MbDqk9XVKprZKiFVO+8WYmhhCrY+rlYSCxwzQG87nGMQMVXATUjB8TwfA Rffb/PeBhUgSy/bbSTT2THkIGzx+A4P8DxuK4SZgcNP4/qVNsH5zd4Zugqo+Cyp22ACN 2E6dSV3wW/xyFOfaKSZouN4vF4xev7x4etV2wNXFcpxl6hau64exQJRepcUQ2jxdbQsq GOsoYFQsBFdk4ydoskAwPsc9rpnewLgZXrLmUVDcOBBGsvxSSXpIrHJflmzsDtoEAnqh kuzZTKvGkJnfyUkanwMcjxfE9PxU6iQRtZKjWyLK2WsFtv71hczYIunVJ084XBbNIQ1E +78Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=CMWvSt5Q2jBoO7ca23RpRfwe7cVE/fnFMb1AA89JFEc=; b=Vbg724Q5cF6FMlHmGeUq52Q29AykUwt0TWOaKynsnC10CzWh+VdimCbEG3LvwJCc+4 +4eApO3eTnGTiNgBT9py9LOOwOO39Kbcjf+eJNPjqBBPjUQQUarFJM9w5DOlxDvZv+Pe puYbM4KirzS0eYJmIg4wQEDYMkboJJgUb7fiN6HvgTDOZ3F0XJw2odsI2oxTPqj4QINC cGUUyOPi8AMkDujS/+2TTYnKJkPrFb+Ro9cRiwzgW8sje2WvDc64xjVp69trWQQG0ej8 DcFSos9VUhozl0lkyBozaot+tZhpsCzoI4ie1OeYj9RNafC4Y9L3Dg+EG7LchmNSZ0/Y SNmw== X-Gm-Message-State: AIVw1120wmXANwJO41LTMcqRk1TUcIruRHFoWGlcr0faQLjR84WSzkmV Yl9A6I8Kela6YA== X-Received: by 10.46.69.137 with SMTP id s131mr3100781lja.31.1499598596412; Sun, 09 Jul 2017 04:09:56 -0700 (PDT) Received: from xi.terra (c-42c8e255.07-184-6d6c6d4.cust.bredbandsbolaget.se. [85.226.200.66]) by smtp.gmail.com with ESMTPSA id b126sm1974643lfe.39.2017.07.09.04.09.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Jul 2017 04:09:55 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1dUA65-0005It-TB; Sun, 09 Jul 2017 13:09:54 +0200 From: Johan Hovold To: Samuel Ortiz Cc: "David S. Miller" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Dan Carpenter , Johan Hovold , stable Subject: [PATCH] NFC: fix device-allocation error return Date: Sun, 9 Jul 2017 13:08:58 +0200 Message-Id: <20170709110858.20331-1-johan@kernel.org> X-Mailer: git-send-email 2.13.2 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org A recent change fixing NFC device allocation itself introduced an error-handling bug by returning an error pointer in case device-id allocation failed. This is clearly broken as the callers still expected NULL to be returned on errors as detected by Dan's static checker. Fix this up by returning NULL in the event that we've run out of memory when allocating a new device id. Note that the offending commit is marked for stable (3.8) so this fix needs to be backported along with it. Fixes: 20777bc57c34 ("NFC: fix broken device allocation") Cc: stable # 3.8 Reported-by: Dan Carpenter Signed-off-by: Johan Hovold --- net/nfc/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/nfc/core.c b/net/nfc/core.c index 5cf33df888c3..c699d64a0753 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -1106,7 +1106,7 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, err_free_dev: kfree(dev); - return ERR_PTR(rc); + return NULL; } EXPORT_SYMBOL(nfc_allocate_device);