From patchwork Thu Dec 10 07:53:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 7815061 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 15ABD9F1C2 for ; Thu, 10 Dec 2015 07:56:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 431632053A for ; Thu, 10 Dec 2015 07:56:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 594EB20575 for ; Thu, 10 Dec 2015 07:56:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753847AbbLJH4o (ORCPT ); Thu, 10 Dec 2015 02:56:44 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:33064 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754445AbbLJHy1 (ORCPT ); Thu, 10 Dec 2015 02:54:27 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NZ400CI0TYO1380@mailout1.w1.samsung.com>; Thu, 10 Dec 2015 07:54:24 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-97-56692fb061d2 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id B1.21.21385.0BF29665; Thu, 10 Dec 2015 07:54:24 +0000 (GMT) Received: from AMDC1061.digital.local ([106.116.147.88]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NZ4003KVTY60T60@eusync3.samsung.com>; Thu, 10 Dec 2015 07:54:24 +0000 (GMT) From: Andrzej Hajda To: linux-wireless@vger.kernel.org (open list:NFC SUBSYSTEM) Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , Lauro Ramos Venancio , Aloisio Almeida Jr , Samuel Ortiz , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] NFC: fdp: fix handling return value of fdp_nci_create_conn Date: Thu, 10 Dec 2015 08:53:02 +0100 Message-id: <1449733982-29120-1-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFJMWRmVeSWpSXmKPExsVy+t/xq7ob9DPDDDauk7K4te4cq8Xi7fdY LDbOWM9qsW3xFGaLy7vmsFm8WXGH3WLtkbvsFqe7WR04POadDPSYO/MXm0ffllWMHp83yQWw RHHZpKTmZJalFunbJXBlrG58zVYwnbui4cpt5gbGJs4uRk4OCQETie79ncwQtpjEhXvr2boY uTiEBJYySkxdf5Udwmliknj5dD4TSBWbgKbE38032UBsEQEbiedbZjGBFDELnGWSePVtMlCC g0NYwFvi72kOkBoWAVWJyRtWgPXyCjhLLFk3gxFim5zEyWOTWScwci9gZFjFKJpamlxQnJSe a6RXnJhbXJqXrpecn7uJERIiX3cwLj1mdYhRgINRiYf3hXRmmBBrYllxZe4hRgkOZiUR3qM/ M8KEeFMSK6tSi/Lji0pzUosPMUpzsCiJ887c9T5ESCA9sSQ1OzW1ILUIJsvEwSnVwMi46M8k fdeZEaZWkfePfnzfMyn4SPqe77rTHfzjDlseU5UJ7r9owLHocpVmugsLW//b5/Vhx2eYxP03 znE+mj67iJ+zpX7n0rO3uV7lKwv1yqUfnNGqZPBV9ynj+jubPQ6vlS3esfLftoktnvO05DI3 Pnr/upSfz927WlQkIfXdHJ5QsbtHdJRYijMSDbWYi4oTASzpDzwNAgAA Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function can return negative values, so its result should be assigned to signed variable. The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 Signed-off-by: Andrzej Hajda --- drivers/nfc/fdp/fdp.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c index ccb07a1..440fac3 100644 --- a/drivers/nfc/fdp/fdp.c +++ b/drivers/nfc/fdp/fdp.c @@ -368,11 +368,10 @@ static int fdp_nci_patch_otp(struct nci_dev *ndev) goto out; /* Patch data connection creation */ - conn_id = fdp_nci_create_conn(ndev); - if (conn_id < 0) { - r = conn_id; + r = fdp_nci_create_conn(ndev); + if (r < 0) goto out; - } + conn_id = r; /* Send the patch over the data connection */ r = fdp_nci_send_patch(ndev, conn_id, NCI_PATCH_TYPE_OTP); @@ -439,11 +438,10 @@ static int fdp_nci_patch_ram(struct nci_dev *ndev) goto out; /* Patch data connection creation */ - conn_id = fdp_nci_create_conn(ndev); - if (conn_id < 0) { - r = conn_id; - goto out; - } + r = fdp_nci_create_conn(ndev); + if (r < 0) + got out; + conn_id = r; /* Send the patch over the data connection */ r = fdp_nci_send_patch(ndev, conn_id, NCI_PATCH_TYPE_RAM);