From patchwork Sat Mar 24 13:44:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 10306045 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.web.codeaurora.org (Postfix) with ESMTP id 60B3C60385 for ; Sat, 24 Mar 2018 13:45:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F635292BD for ; Sat, 24 Mar 2018 13:45:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EB7B292C1; Sat, 24 Mar 2018 13:45:14 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 BA857292BD for ; Sat, 24 Mar 2018 13:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752017AbeCXNpL (ORCPT ); Sat, 24 Mar 2018 09:45:11 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:41832 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751923AbeCXNpK (ORCPT ); Sat, 24 Mar 2018 09:45:10 -0400 Received: by mail-qt0-f195.google.com with SMTP id d18so2982585qtl.8 for ; Sat, 24 Mar 2018 06:45:10 -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=bBswvupqln8ZRwFShZNfTbIxvBqsrkKG9O3ka3oji7E=; b=i66saajucr4CVCNd3gs5OkPIO28qTcHqDnHnZE8oLvqXh6DuSf0aRNx48JR9kNuwdj QI+1BzQmHWt9RGk1bsMx/BbffgiThxkqvGlTzwsA4ICJW8dNpbM8ZLHaJatxQZElq+78 1KUQKWAWjIflYWC7tEoLqGDKLTRi6xjyv1FyPeOYrI7TARd2Huc1L0emI2D2CBljVn0r ugpRhzmpT+TapuNsorwN54XCCKUA7fk0QnP3B917BrPFyhUIXP1Cl0IlBPL4iUBq2p4Q 5IcDWujuW9S3UiIASEXIJKiP8Y1hoATDdnpX8Gab0A+hpJeRBNJ5ynYc7FMegca0VEpG 6NZA== 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=bBswvupqln8ZRwFShZNfTbIxvBqsrkKG9O3ka3oji7E=; b=n2XyZ6XY/CpXui58C5tNBxo9qeNaVfrqJmSj0o9GE42EQtr4OWdIodZoFIJiSI8Rb0 k2lsLTeX9YceZMfutaszm9xmbPmpUxqjHeLSQMQSTUCCJsGCGhOL2ut79mcEri6l6Isg O+Ibi8RZ7Hz5ths5rF4mjJiuFpv5iAt9iZt7ovQ+d06kMjxiH/bZUemb8SunUY8+jJ1W JIPRzXEzvp5gm5AeXYdrw90487DShUYjVW9yth7HMJ+0K5lY+ComDsjgZPB1ML51Hsls 5bcF3rqe9fZRn165dDFCKrtcsY7S/uJ+o1EfiNI6ZANlEHZjUvEWw0dKTSylqd+rR7E/ Ibgw== X-Gm-Message-State: AElRT7GFZluPEvGt8RAQUCTs9o1Y/PoCciLLH2FyVaHVFJXovhaa0WoB X0kDgsIYszFJvbH3cpcSQ3Q= X-Google-Smtp-Source: AG47ELu/bUnVW5fQHI+ynUdGn8OL9/dP9kKxd1WC6Y9qcCr8NnWhEDbaUjSUmd6LjuPbkk1DB10ecw== X-Received: by 10.237.33.34 with SMTP id 31mr32577949qtc.211.1521899110185; Sat, 24 Mar 2018 06:45:10 -0700 (PDT) Received: from localhost.localdomain ([187.180.181.214]) by smtp.gmail.com with ESMTPSA id c25sm7944552qtn.9.2018.03.24.06.45.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 24 Mar 2018 06:45:09 -0700 (PDT) From: Fabio Estevam To: sameo@linux.intel.com Cc: linux-wireless@vger.kernel.org, christophe.ricard@gmail.com, linux-nfc@lists.01.org, Fabio Estevam Subject: [PATCH 1/2] nfc: st21nfca: Check for devm_kzalloc() failure Date: Sat, 24 Mar 2018 10:44:58 -0300 Message-Id: <1521899099-23634-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 2.7.4 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 From: Fabio Estevam devm_kzalloc() may fail, so we should better check for error and propagate the error in the case of allocation failure. This avoids a potential NULL pointer dereference later on. Signed-off-by: Fabio Estevam --- drivers/nfc/st21nfca/se.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nfc/st21nfca/se.c b/drivers/nfc/st21nfca/se.c index 4bed9e84..fd967a3 100644 --- a/drivers/nfc/st21nfca/se.c +++ b/drivers/nfc/st21nfca/se.c @@ -328,6 +328,8 @@ int st21nfca_connectivity_event_received(struct nfc_hci_dev *hdev, u8 host, transaction = (struct nfc_evt_transaction *)devm_kzalloc(dev, skb->len - 2, GFP_KERNEL); + if (!transaction) + return -ENOMEM; transaction->aid_len = skb->data[1]; memcpy(transaction->aid, &skb->data[2],