From patchwork Thu Aug 20 09:19:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 265576 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2C01C433DF for ; Thu, 20 Aug 2020 11:17:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAD9620885 for ; Thu, 20 Aug 2020 11:17:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597922278; bh=eQHLXXOPZUp7EIkYRyaxbfJIa9qUIejXd8pgy1zPkpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zzE8EZWfZjFIbtBnPGNO5wyMxY3HWmwzt6UFhTBTKp1wx/IHix+i+9AnRlkT/pQYw Ld553VCY2KJF05pT4yfndc92+Uy2J2eOUspls1B+Jo4D/IwuIKPaUzq40M4CFNYoGH quKz1uW9N0f0QKSa1Db1vhrFxFNnlYFZzP0LOe5o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728834AbgHTLR5 (ORCPT ); Thu, 20 Aug 2020 07:17:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:39894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730305AbgHTKIL (ORCPT ); Thu, 20 Aug 2020 06:08:11 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DB0002067C; Thu, 20 Aug 2020 10:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597918091; bh=eQHLXXOPZUp7EIkYRyaxbfJIa9qUIejXd8pgy1zPkpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kig3JS05NB8j78q/npjXo0ZpNpOAivYzE+yAJb06PSfA6oda4Bi5F5lN/K5CKslUn nGof1UgmPtW2xDS47lLIb4tea6WuX1FzM7Y668nu4Go3FsZyMrVr7AToHGKWntYadk 30orXFvDNNJCLoFdavmcwIWqFqnEoFPYIwNHQpvU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wolfram Sang , Alain Volmat , Wolfram Sang , Sasha Levin Subject: [PATCH 4.14 022/228] i2c: slave: improve sanity check when registering Date: Thu, 20 Aug 2020 11:19:57 +0200 Message-Id: <20200820091608.641986122@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091607.532711107@linuxfoundation.org> References: <20200820091607.532711107@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Wolfram Sang [ Upstream commit 1b1be3bf27b62f5abcf85c6f3214bdb9c7526685 ] Add check for ERR_PTR and simplify code while here. Signed-off-by: Wolfram Sang Reviewed-by: Alain Volmat Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/i2c-core-slave.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/i2c/i2c-core-slave.c b/drivers/i2c/i2c-core-slave.c index 4a78c65e99713..21051aba39e3a 100644 --- a/drivers/i2c/i2c-core-slave.c +++ b/drivers/i2c/i2c-core-slave.c @@ -22,10 +22,8 @@ int i2c_slave_register(struct i2c_client *client, i2c_slave_cb_t slave_cb) { int ret; - if (!client || !slave_cb) { - WARN(1, "insufficient data\n"); + if (WARN(IS_ERR_OR_NULL(client) || !slave_cb, "insufficient data\n")) return -EINVAL; - } if (!(client->flags & I2C_CLIENT_SLAVE)) dev_warn(&client->dev, "%s: client slave flag not set. You might see address collisions\n",