Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp776746ybt; Fri, 19 Jun 2020 13:29:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykVsSNRRGEpuvn694GyAqJSAAkr/KY0cvZIgP88lh7qhN6mpB3L3ibDo40ZS/1lk9iF2TY X-Received: by 2002:a17:907:b15:: with SMTP id h21mr5416344ejl.450.1592598564539; Fri, 19 Jun 2020 13:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592598564; cv=none; d=google.com; s=arc-20160816; b=mpZGlBpvmfidojFBEWzY+sr64GeXeNukishmpRDM/u4a9eECEee3N1WGeZKbkCOqsL PwoaS8Hmx6ME7NfXqvlSBe+mG5d1/uBvhxYFC/x1J1UdPjMfglOrb4nMvPg631xMd4OW dJj3xDsp7XXTJfA9yVrgDGNdPH3KQV2fXRihv1ZOhrIZWGxiSJ3fe8rTAR0pLzPsw6Np YgIql6vnNeYi38GOfq2WZyzwb6lb7DzWP+LFTmwcoRr0oBzYpM1jw52m2Sx4Wl6eHZ34 JK8OlWnUW7auq5f7xix4tH8vktCuz/u/r1UYUAGU+pYvjQV7i3N4CSt2iJSMsRng3/D2 2Qzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZkP2stLADHfE584sKM91Erm+NqSDfTRa2CkT4cuFMB4=; b=cjJrDozNyVhL6ZwNCcCPP/kWGlFjGFG9gRny9S8Irmqyyql1u+BI+e6RQbXy70zyQp yQYQ7BiKrgPTHCe5DFvyJFa8q2CKxRP3WbFeVyJIi63PxhyVgDu1bF0ivqsIF4Df+jrO tb/G0LVLO02u6JO3V4YKAw4XPwZviwEeeR/RRtnS66htt2NTTxsRUnmqB7vVGBEWGGyw wqQ6VcnotrExw6VbL0GzDEtJWc8KQNQS/4gbZJ3NB//gnHcyav2o/P2ViDEKmKCzBbu6 qVhHr/ZmUjJlexVNdYlfw1XgOnQdmfTiZxHZ5+mPelagy5YHwY4ZvrQHVVq10Y+bpHad CK+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IjEdJSun; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a11si4736343eds.271.2020.06.19.13.29.02; Fri, 19 Jun 2020 13:29:24 -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=@kernel.org header.s=default header.b=IjEdJSun; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391061AbgFSPDy (ORCPT + 99 others); Fri, 19 Jun 2020 11:03:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:60434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391036AbgFSPDk (ORCPT ); Fri, 19 Jun 2020 11:03:40 -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 0FE1A206DB; Fri, 19 Jun 2020 15:03:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592579020; bh=m/XRWXAKcfR55buGyTcsv2d4DhNlb5CKM6plfkXTgCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IjEdJSunMxbNJn8wX1nplWLCe4dZgsHVy3GjdrCbEX1kWxJjlQAOaqXJDB3eXJ1jC O3tlZkDnyyiO0ROMtkZt6D5pxQwf/z2fnHy53eek8HtJGAh/pQq8G3hT+plkipEz8l kcggvmxuxM+MSViKfh0N+FdIv9vTk4mQbItiiZIE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Wei Yongjun , Johan Hovold Subject: [PATCH 4.19 245/267] gnss: sirf: fix error return code in sirf_probe() Date: Fri, 19 Jun 2020 16:33:50 +0200 Message-Id: <20200619141700.438090577@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wei Yongjun commit 43d7ce70ae43dd8523754b17f567417e0e75dbce upstream. Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. This avoids a use-after-free in case the driver is later unbound. Fixes: d2efbbd18b1e ("gnss: add driver for sirfstar-based receivers") Reported-by: Hulk Robot Signed-off-by: Wei Yongjun [ johan: amend commit message; mention potential use-after-free ] Cc: stable # 4.19 Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/gnss/sirf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/gnss/sirf.c +++ b/drivers/gnss/sirf.c @@ -292,14 +292,18 @@ static int sirf_probe(struct serdev_devi data->on_off = devm_gpiod_get_optional(dev, "sirf,onoff", GPIOD_OUT_LOW); - if (IS_ERR(data->on_off)) + if (IS_ERR(data->on_off)) { + ret = PTR_ERR(data->on_off); goto err_put_device; + } if (data->on_off) { data->wakeup = devm_gpiod_get_optional(dev, "sirf,wakeup", GPIOD_IN); - if (IS_ERR(data->wakeup)) + if (IS_ERR(data->wakeup)) { + ret = PTR_ERR(data->wakeup); goto err_put_device; + } /* * Configurations where WAKEUP has been left not connected,