Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2704592pxy; Mon, 3 May 2021 06:18:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSPgphJqlkiG8Z2JXrdcfLaskjtnx9sfbotUlXj+qR5l6xM54cXw/HXqcwIxafiQyOycaY X-Received: by 2002:a62:5209:0:b029:278:648f:99b6 with SMTP id g9-20020a6252090000b0290278648f99b6mr18492242pfb.9.1620047887367; Mon, 03 May 2021 06:18:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620047887; cv=none; d=google.com; s=arc-20160816; b=LiJY/qp4SuI8EuTwgRqwD4Z9Uu32DDXpX8ALk9mY+jzWaV57DhDk7CkxXpeJ9PJp8u SenO5wVainF67Y5fJEWzeF2iYLUfAy2Pku4qwwUVYIH7RQv3BOFiIADU8OcwA0y8zN08 l+OhHs1mpNo2QrZtQC9qOuGt2Ep/SKVIOpVfnjpOqGj+g3Pr9x9HH/uqdDzhO9T0zxR2 RVrhMJNr7evqXyKwPbTHYTlKVLUi0W+oYgGZhuZQoMMk1/mcIWvr31xM3fNs3vtHuwyL pNBMPA0J1NMVsKR9MM/3eVzwvIR1+T0TCLKgkl48FDxuCnO+lLXOywBBUetOYSNZKXMr wD5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=axDwsaBBU2f1aZQyl6LbVJq+TG60Vi1pbgkR97/K25U=; b=b7ZukYyUg680wpq5b7deGhy8HNXS/C8qvy6nQy+S+PKYR3zt12vujPynnvjgK5Ja4O TQVKrI3jKxrqER/9kQxxQoLJ9FesV7gQDLDL35Aumal57JXxUIxKuTMztfLatLn+tRdE xd/PVs1FG+mh0pNTIJN0Plxzvt4blE2PZpX5Ky4DhxiFfd0I7jcpLdNPB+se2wjCyFFg 2ijeK1VDWVCQDwW/cQ8TCPIc3KAYOhCXYqHJXJjEu6koeUVYYH/NTfamK7P3zwUNaglB OBuAWmfLhh0JpFieq1xDvp0XyER2dOmDeeeDg5hXcVGghYkHG6Sxtsu21/5JDdPm4kW2 w/Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qkFkWXmG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a22si14900244pgi.543.2021.05.03.06.17.54; Mon, 03 May 2021 06:18:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qkFkWXmG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233376AbhECMCF (ORCPT + 99 others); Mon, 3 May 2021 08:02:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:35144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233918AbhECMBQ (ORCPT ); Mon, 3 May 2021 08:01:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 01414613B4; Mon, 3 May 2021 12:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620043222; bh=dht7hj5yETD9puSVikZtzaLEx4rnyGrXDO/jtaxric4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qkFkWXmG0UBOLLc0rk09nw0fFZ2cPBEWDmLefanuheTsle/OtBejvjhcTrqsdQ670 pYCV8cWkS/BubTQ5JnEkDkBdtNu+SOGnRS9OBcjKUW0xEiIOdYSNeD6D/Rds1+kX+s s0eHI7IekOGUcqeCgW1Jn0c3RibPksjhv6wWYPp8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Phillip Potter , "David S . Miller" , Greg Kroah-Hartman Subject: [PATCH 47/69] isdn: mISDN: correctly handle ph_info allocation failure in hfcsusb_ph_info Date: Mon, 3 May 2021 13:57:14 +0200 Message-Id: <20210503115736.2104747-48-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503115736.2104747-1-gregkh@linuxfoundation.org> References: <20210503115736.2104747-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Phillip Potter Modify return type of hfcusb_ph_info to int, so that we can pass error value up the call stack when allocation of ph_info fails. Also change three of four call sites to actually account for the memory failure. The fourth, in ph_state_nt, is infeasible to change as it is in turn called by ph_state which is used as a function pointer argument to mISDN_initdchannel, which would necessitate changing its signature and updating all the places where it is used (too many). Fixes original flawed commit (38d22659803a) from the University of Minnesota. Cc: David S. Miller Signed-off-by: Phillip Potter Signed-off-by: Greg Kroah-Hartman --- drivers/isdn/hardware/mISDN/hfcsusb.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c index 4bb470d3963d..cd5642cef01f 100644 --- a/drivers/isdn/hardware/mISDN/hfcsusb.c +++ b/drivers/isdn/hardware/mISDN/hfcsusb.c @@ -46,7 +46,7 @@ static void hfcsusb_start_endpoint(struct hfcsusb *hw, int channel); static void hfcsusb_stop_endpoint(struct hfcsusb *hw, int channel); static int hfcsusb_setup_bch(struct bchannel *bch, int protocol); static void deactivate_bchannel(struct bchannel *bch); -static void hfcsusb_ph_info(struct hfcsusb *hw); +static int hfcsusb_ph_info(struct hfcsusb *hw); /* start next background transfer for control channel */ static void @@ -241,7 +241,7 @@ hfcusb_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb) * send full D/B channel status information * as MPH_INFORMATION_IND */ -static void +static int hfcsusb_ph_info(struct hfcsusb *hw) { struct ph_info *phi; @@ -249,6 +249,9 @@ hfcsusb_ph_info(struct hfcsusb *hw) int i; phi = kzalloc(struct_size(phi, bch, dch->dev.nrbchan), GFP_ATOMIC); + if (!phi) + return -ENOMEM; + phi->dch.ch.protocol = hw->protocol; phi->dch.ch.Flags = dch->Flags; phi->dch.state = dch->state; @@ -260,6 +263,8 @@ hfcsusb_ph_info(struct hfcsusb *hw) _queue_data(&dch->dev.D, MPH_INFORMATION_IND, MISDN_ID_ANY, struct_size(phi, bch, dch->dev.nrbchan), phi, GFP_ATOMIC); kfree(phi); + + return 0; } /* @@ -344,8 +349,7 @@ hfcusb_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb) ret = l1_event(dch->l1, hh->prim); break; case MPH_INFORMATION_REQ: - hfcsusb_ph_info(hw); - ret = 0; + ret = hfcsusb_ph_info(hw); break; } @@ -400,8 +404,7 @@ hfc_l1callback(struct dchannel *dch, u_int cmd) hw->name, __func__, cmd); return -1; } - hfcsusb_ph_info(hw); - return 0; + return hfcsusb_ph_info(hw); } static int @@ -743,8 +746,7 @@ hfcsusb_setup_bch(struct bchannel *bch, int protocol) handle_led(hw, (bch->nr == 1) ? LED_B1_OFF : LED_B2_OFF); } - hfcsusb_ph_info(hw); - return 0; + return hfcsusb_ph_info(hw); } static void -- 2.31.1