From patchwork Thu Aug 5 18:31:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12421811 X-Patchwork-Delegate: kuba@kernel.org 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=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,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 76101C4338F for ; Thu, 5 Aug 2021 18:38:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5059A60F01 for ; Thu, 5 Aug 2021 18:38:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241499AbhHESi4 (ORCPT ); Thu, 5 Aug 2021 14:38:56 -0400 Received: from mga01.intel.com ([192.55.52.88]:4238 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241019AbhHESiz (ORCPT ); Thu, 5 Aug 2021 14:38:55 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10067"; a="236197431" X-IronPort-AV: E=Sophos;i="5.84,296,1620716400"; d="scan'208";a="236197431" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2021 11:38:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,296,1620716400"; d="scan'208";a="419925391" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 05 Aug 2021 11:38:33 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7FB9D15E; Thu, 5 Aug 2021 21:31:06 +0300 (EEST) From: Andy Shevchenko To: "David S. Miller" , Sergey Ryazanov , Loic Poulain , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Johannes Berg , Jakub Kicinski , Andy Shevchenko Subject: [PATCH v1 1/1] wwan: core: Avoid returning error pointer from wwan_create_dev() Date: Thu, 5 Aug 2021 21:31:00 +0300 Message-Id: <20210805183100.49071-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org wwan_create_dev() is expected to return either valid pointer or NULL, In some cases it might return the error pointer. Prevent this by converting it to NULL after wwan_dev_get_by_parent(). Fixes: 9a44c1cc6388 ("net: Add a WWAN subsystem") Signed-off-by: Andy Shevchenko --- drivers/net/wwan/wwan_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c index 674a81d79db3..35e10a98e774 100644 --- a/drivers/net/wwan/wwan_core.c +++ b/drivers/net/wwan/wwan_core.c @@ -160,7 +160,9 @@ static struct wwan_device *wwan_create_dev(struct device *parent) /* If wwandev already exists, return it */ wwandev = wwan_dev_get_by_parent(parent); - if (!IS_ERR(wwandev)) + if (IS_ERR(wwandev)) + wwandev = NULL; + else goto done_unlock; id = ida_alloc(&wwan_dev_ids, GFP_KERNEL);