From patchwork Thu Jun 28 02:32:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 140382 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1622059ljj; Wed, 27 Jun 2018 19:33:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdYS7eR+2YzF2koBbb/YP3PPHDhFBcT88m/e8hHAqgZCEDVjr5enzagOH17GQgK1hAiK3Wt X-Received: by 2002:aa7:84cf:: with SMTP id x15-v6mr8235920pfn.220.1530153208515; Wed, 27 Jun 2018 19:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530153208; cv=none; d=google.com; s=arc-20160816; b=fWZBNKG1f2Td9ZTCD9bsMzmTBi9QWAStDsAYcLEckUV4C0mHlj8Er9lqp8phq66K+Q yUuvTfN+VzK5sosOoVOKvVtfBXWT0JpRYfjyckodsgHFrbkrhugk2Sy/ccQejtNGrTSw Qg39YgbrhGxznPzHFzoy/GJkFNUHKUGGWa/sm3HlM4jFDliK/OQDCH13nXAZGcuc567/ YPAnm7oy/tByQ1pE167ARogYUF1W8ShGSUI9H83RWBSS/0+jqFAkWfG1NUmIBvED+wFS LNXVezaV73Ovmh0G9EdvAY9oEDLfiMhp7mHoZy2KfdoIHeNqKVxjpISUVWdm2z4Nvsdv LdRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=5Ei8DfUbEj09xKrPzL9OuN846n3Yz2bUT6zLG6DznuQ=; b=jdBCgFIl5qvl/OtVBb3zfBoSY8+iQjgUD5lblkdfFYOAFEsrY168AqdrdJa+OuIrKQ XjYv0JTQDurt89GyR9j9fICmVEXJ2BwsM4N9JWpIePW7AtkGjTfYAD/LXnfTkuIWNMAD GPY3Pz9Hi48a+JcMZZuiapm6/Xr8APhN7bcGSDsrsG/6FziKDLcUWzYqyaHU09lBxghS 70V21du2noz8Zswqdw7KpWmIPSNEbvRS+B4KCvDdcvYUxD1KLQejvOIPy2FRbmMIak3X xm3TXpBCBmQsEbLqvMR8+7BXROnKd9AlbXaqx2lGhiEeVN0IWz1Et+AwTnrPTAH5cMhP MX4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ha83AOvD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x33-v6si5463973plb.512.2018.06.27.19.33.28; Wed, 27 Jun 2018 19:33:28 -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=pass header.i=@linaro.org header.s=google header.b=ha83AOvD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753212AbeF1Cd0 (ORCPT + 31 others); Wed, 27 Jun 2018 22:33:26 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:41475 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753165AbeF1CdY (ORCPT ); Wed, 27 Jun 2018 22:33:24 -0400 Received: by mail-pl0-f65.google.com with SMTP id w8-v6so1976394ply.8 for ; Wed, 27 Jun 2018 19:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=5Ei8DfUbEj09xKrPzL9OuN846n3Yz2bUT6zLG6DznuQ=; b=ha83AOvDWC60d7qhTitImB8kHqm52M8oEFIhq4PGUaniUa33OgGdTTwMDVtl/O6nyi fbJ9JvsZlbcSyhQN2TEH/hfJBnORVp527dTWbPNKwKRrJFG1JxMAoRso27AWknaWsnAQ lQ/NPs/8P9VGbPT8/Pb5h9xfHxcGl+xblEbCI= 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=5Ei8DfUbEj09xKrPzL9OuN846n3Yz2bUT6zLG6DznuQ=; b=fkZo7hwps83vJKDn5vbp30joQDVwlUHTKdBp9p9+Gms5KVNt8yZ90g7vbnP4DCckeu DPV9BnQVvIa7+ZKRwRqKm4zxdMtJQitDkBFVp5lM3cQ9lsV31E+ulABPk+Z5bjZdISDi DbN+SbIZYK+Ll2FCUDJ8A8rODk1ZHGAp18SnlvX0K9GQ6e+gLNJALeGX0tmgHxyX4VKT N60kYKkN1djxj3uDm2ZWPxzO4JEyYwAWDoBsz+ahCP0mufa4MRwhN31X+zEbz2mK6qW2 D+XTDn7htFbsPPg/DQhRT6/2vkT1a1fbVLaFxkdLfE/4rh39uq1oOfG5w383Uyf0O2/E dVLQ== X-Gm-Message-State: APt69E2jNqS70gtZZL0Njph+zlYfEE6DJSyoFs2I7UC1ALsSFe9lYpxq 0Ow0RpQYWI+dnlN52U2vbEOlng== X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr8370387plp.36.1530153204170; Wed, 27 Jun 2018 19:33:24 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id n9-v6sm10139289pgu.77.2018.06.27.19.33.21 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jun 2018 19:33:23 -0700 (PDT) From: Baolin Wang To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: broonie@kernel.org, dan.carpenter@oracle.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH] hwspinlock: Fix incorrect return pointers Date: Thu, 28 Jun 2018 10:32:21 +0800 Message-Id: <782fc498b4f4c6e8130d64face93023eb3dc9866.1530152980.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The commit 4f1acd758b08 ("hwspinlock: Add devm_xxx() APIs to request/free hwlock") introduces one bug, that will return one error pointer if failed to request one hwlock, but we expect NULL pointer on error for consumers. This patch will fix this issue. Reported-by: Dan Carpenter Signed-off-by: Baolin Wang --- drivers/hwspinlock/hwspinlock_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 1.7.9.5 diff --git a/drivers/hwspinlock/hwspinlock_core.c b/drivers/hwspinlock/hwspinlock_core.c index e16d648..2bad40d 100644 --- a/drivers/hwspinlock/hwspinlock_core.c +++ b/drivers/hwspinlock/hwspinlock_core.c @@ -877,10 +877,10 @@ struct hwspinlock *devm_hwspin_lock_request(struct device *dev) ptr = devres_alloc(devm_hwspin_lock_release, sizeof(*ptr), GFP_KERNEL); if (!ptr) - return ERR_PTR(-ENOMEM); + return NULL; hwlock = hwspin_lock_request(); - if (!IS_ERR(hwlock)) { + if (hwlock) { *ptr = hwlock; devres_add(dev, ptr); } else { @@ -913,10 +913,10 @@ struct hwspinlock *devm_hwspin_lock_request_specific(struct device *dev, ptr = devres_alloc(devm_hwspin_lock_release, sizeof(*ptr), GFP_KERNEL); if (!ptr) - return ERR_PTR(-ENOMEM); + return NULL; hwlock = hwspin_lock_request_specific(id); - if (!IS_ERR(hwlock)) { + if (hwlock) { *ptr = hwlock; devres_add(dev, ptr); } else {