Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753299AbeADOzj (ORCPT + 1 other); Thu, 4 Jan 2018 09:55:39 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:53259 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753092AbeADOzh (ORCPT ); Thu, 4 Jan 2018 09:55:37 -0500 Date: Thu, 4 Jan 2018 17:55:22 +0300 From: Dan Carpenter To: Xiongwei Song Cc: gregkh@linuxfoundation.org, arve@android.com, tkjos@android.com, maco@android.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: android: check the return value of register_shrinker Message-ID: <20180104145522.ru7twjwzmzzrqatd@mwanda> References: <20180104000853.1142-1-sxwjean@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180104000853.1142-1-sxwjean@gmail.com> User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8763 signatures=668651 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=867 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801040205 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Thu, Jan 04, 2018 at 08:08:53AM +0800, Xiongwei Song wrote: > register_shrinker call is made in ashmem_init, it may return error code, > so we need to check it. > > Signed-off-by: Xiongwei Song > --- > drivers/staging/android/ashmem.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c > index 4e8947923904..0b23c3e25cd4 100644 > --- a/drivers/staging/android/ashmem.c > +++ b/drivers/staging/android/ashmem.c > @@ -854,12 +854,18 @@ static int __init ashmem_init(void) > goto out_free2; > } > > - register_shrinker(&ashmem_shrinker); > + ret = register_shrinker(&ashmem_shrinker); > + if (unlikely(ret)) { Don't add the unlikely() here. It hurts readability and this is not a fast path. I know the other callers all have it... :/ regards, dan carpenter