Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4462693ybb; Tue, 7 Apr 2020 08:00:42 -0700 (PDT) X-Google-Smtp-Source: APiQypJTcaYzy4XutIK0DVLVH6nYXRCqhcXPkrMczYqtULIeR2X2MB3Ki9stg+h4frfhJmxjkQwB X-Received: by 2002:aca:5b04:: with SMTP id p4mr2147754oib.105.1586271642084; Tue, 07 Apr 2020 08:00:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586271642; cv=none; d=google.com; s=arc-20160816; b=v73aS0zA29VVBYnk0yRisZbo4/XD/CjmkCK6ax+t6KeZBOUNcmQqSFaQS/gIyC8who 50Ex0Q6fQge0F5AZyB5Aw1qGwj4drKF4rgbKh+Ezi0BkdJC7RF9wti8r2Y3QF1NlBAyl CZoka/RCU75ylrmVvTMGS2SqBclgYpiuXN8MkJcSZi49nLBi4fr2cGE5RNwj36k2UFu2 hrzA8oJAygb/4amqAOyzbCkw6mMYMC02KyxOxUYbn3jaMsTVn1SzWoydGxOJre2bxZKv X3gwnAMlyVfnKrnxh5PswiRg8GexTI7BQxy4iC+kTkQkJ1A2DXDNz6vr59rGy0Sx3fj2 5JXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=auVLr2it7T+z8tE89vAXBl2j56M0Z9mr57qUHDGowj0=; b=v4VJMHXc/Ej6DtxQ5SHKdDQHCQo75FUUPhKgZGgVN4W6V3nJnDE2xs54eP2lOC+AuT fnZuskh6dADzIMmGZGquWTykLCePsGuhSho3hPt+f29PDEE96alb9BxL5YKrKW677hLM v33sL952no6gQW1d9ilVZ/oeZ3X3n3HnkfTtTs9JNrx67Oy0n/d90yz9eMIiKHyTlWoL oVcx4yE9EXNOt+cuSZ4fc8pAMoH1l7EfP+jDTDE/7QFGKzbbLZ6agxIeDB275F6KKwC7 JSP5IyE7XnHJshjowQqIs2PTjCyUkx3B2pBE9na/WjcPKq6JdP35C7qqYCSfeCznQti4 4A8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si1288969otk.166.2020.04.07.08.00.27; Tue, 07 Apr 2020 08:00:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729252AbgDGO6c (ORCPT + 99 others); Tue, 7 Apr 2020 10:58:32 -0400 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:3082 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728855AbgDGO6c (ORCPT ); Tue, 7 Apr 2020 10:58:32 -0400 Received: from pps.filterd (m0167088.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 037EsWgJ031822; Tue, 7 Apr 2020 10:58:30 -0400 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com with ESMTP id 306m36b0x4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Apr 2020 10:58:30 -0400 Received: from SCSQMBX11.ad.analog.com (scsqmbx11.ad.analog.com [10.77.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 037EwSLW001741 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Tue, 7 Apr 2020 10:58:28 -0400 Received: from SCSQMBX10.ad.analog.com (10.77.17.5) by SCSQMBX11.ad.analog.com (10.77.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Tue, 7 Apr 2020 07:58:27 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by SCSQMBX10.ad.analog.com (10.77.17.5) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Tue, 7 Apr 2020 07:58:26 -0700 Received: from localhost.localdomain ([10.48.65.12]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 037EwPW2021183; Tue, 7 Apr 2020 10:58:25 -0400 From: Alexandru Ardelean To: , CC: , Alexandru Ardelean Subject: [PATCH] iio: buffer: remove null-checks for 'indio_dev->info' Date: Tue, 7 Apr 2020 17:59:18 +0300 Message-ID: <20200407145918.6833-1-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-ADIRoutedOnPrem: True X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-07_07:2020-04-07,2020-04-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 clxscore=1015 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004070128 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Checking for 'indio_dev->info' is an impossible condition, since an IIO device should NOT be able to register without that information. The iio_device_register() function won't allow an IIO device to register if 'indio_dev->info' is NULL. If that information somehow becomes NULL, then we're likely busted anyway and we should crash the system, if we haven't already. Signed-off-by: Alexandru Ardelean --- drivers/iio/industrialio-buffer.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index e6fa1a4e135d..c96071bfada8 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -54,10 +54,6 @@ static bool iio_buffer_ready(struct iio_dev *indio_dev, struct iio_buffer *buf, size_t avail; int flushed = 0; - /* wakeup if the device was unregistered */ - if (!indio_dev->info) - return true; - /* drain the buffer if it was disabled */ if (!iio_buffer_is_active(buf)) { to_wait = min_t(size_t, to_wait, 1); @@ -109,9 +105,6 @@ ssize_t iio_buffer_read_outer(struct file *filp, char __user *buf, size_t to_wait; int ret = 0; - if (!indio_dev->info) - return -ENODEV; - if (!rb || !rb->access->read) return -EINVAL; @@ -131,11 +124,6 @@ ssize_t iio_buffer_read_outer(struct file *filp, char __user *buf, add_wait_queue(&rb->pollq, &wait); do { - if (!indio_dev->info) { - ret = -ENODEV; - break; - } - if (!iio_buffer_ready(indio_dev, rb, to_wait, n / datum_size)) { if (signal_pending(current)) { ret = -ERESTARTSYS; @@ -171,7 +159,7 @@ __poll_t iio_buffer_poll(struct file *filp, struct iio_dev *indio_dev = filp->private_data; struct iio_buffer *rb = indio_dev->buffer; - if (!indio_dev->info || rb == NULL) + if (rb == NULL) return 0; poll_wait(filp, &rb->pollq, wait); @@ -1100,11 +1088,6 @@ int iio_update_buffers(struct iio_dev *indio_dev, goto out_unlock; } - if (indio_dev->info == NULL) { - ret = -ENODEV; - goto out_unlock; - } - ret = __iio_update_buffers(indio_dev, insert_buffer, remove_buffer); out_unlock: -- 2.17.1