From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752492AbcEDLeT (ORCPT ); Wed, 4 May 2016 07:34:19 -0400 Received: from conssluserg-04.nifty.com ([210.131.2.83]:24797 "EHLO conssluserg-04.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750879AbcEDLeR (ORCPT ); Wed, 4 May 2016 07:34:17 -0400 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com u44BYAlb024041 X-Nifty-SrcIP: [209.85.161.182] MIME-Version: 1.0 In-Reply-To: <8236507.We1UVOf0nF@wuerfel> References: <1462360671-13668-1-git-send-email-yamada.masahiro@socionext.com> <8236507.We1UVOf0nF@wuerfel> Date: Wed, 4 May 2016 20:34:09 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] reset: allow to pass NULL pointer to reset_control_put() From: Masahiro Yamada To: Arnd Bergmann Cc: Linux Kernel Mailing List , Philipp Zabel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Arnd, 2016-05-04 20:24 GMT+09:00 Arnd Bergmann : > On Wednesday 04 May 2016 20:17:51 Masahiro Yamada wrote: >> Currently, reset_control_put() just returns for error pointer, >> but not for NULL pointer. This is not reasonable. >> >> Passing NULL pointer should be allowed as well to make failure path >> handling easier. >> >> Signed-off-by: Masahiro Yamada >> --- >> >> drivers/reset/core.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/reset/core.c b/drivers/reset/core.c >> index 181b05d..7bb16d1 100644 >> --- a/drivers/reset/core.c >> +++ b/drivers/reset/core.c >> @@ -288,7 +288,7 @@ EXPORT_SYMBOL_GPL(reset_control_get); >> >> void reset_control_put(struct reset_control *rstc) >> { >> - if (IS_ERR(rstc)) >> + if (IS_ERR_OR_NULL(rstc)) >> return; >> >> module_put(rstc->rcdev->owner); > > Using IS_ERR_OR_NULL() normally indicates that there is something > wrong with the API, or with the caller. > > What exactly is the idea behind treating an error pointer as a valid > input to reset_control_put() here? Maybe it should just test for > NULL? > I thought about that a bit, but there might be some (not nice) drivers that rely on the current behavior. I did not want to break any boards with my patch. So, should it be if (!rstc) return; or, perhaps if (!rstc || WARN_ON_ONCE(IS_ERR(rstc))) return; ? -- Best Regards Masahiro Yamada