From patchwork Thu Nov 12 15:13:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nuno Sa X-Patchwork-Id: 11900483 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BCA4E697 for ; Thu, 12 Nov 2020 15:12:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3F8122240 for ; Thu, 12 Nov 2020 15:12:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728218AbgKLPMH (ORCPT ); Thu, 12 Nov 2020 10:12:07 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:1782 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbgKLPMG (ORCPT ); Thu, 12 Nov 2020 10:12:06 -0500 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0ACFBpSc000353; Thu, 12 Nov 2020 10:11:51 -0500 Received: from nwd2mta3.analog.com ([137.71.173.56]) by mx0a-00128a01.pphosted.com with ESMTP id 34nsc99kmx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 12 Nov 2020 10:11:50 -0500 Received: from ASHBMBX9.ad.analog.com (ashbmbx9.ad.analog.com [10.64.17.10]) by nwd2mta3.analog.com (8.14.7/8.14.7) with ESMTP id 0ACFBkxf049264 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Thu, 12 Nov 2020 10:11:46 -0500 Received: from ASHBMBX8.ad.analog.com (10.64.17.5) by ASHBMBX9.ad.analog.com (10.64.17.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Thu, 12 Nov 2020 10:11:45 -0500 Received: from zeus.spd.analog.com (10.66.68.11) by ASHBMBX8.ad.analog.com (10.64.17.5) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Thu, 12 Nov 2020 10:11:45 -0500 Received: from nsa.sphairon.box ([10.44.3.53]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 0ACFBhCe018749; Thu, 12 Nov 2020 10:11:45 -0500 From: =?utf-8?q?Nuno_S=C3=A1?= To: CC: Jonathan Cameron , Lars-Peter Clausen , Peter Meerwald-Stadler Subject: [RFC PATCH 1/1] iio: buffer: Sanity check buffer callback Date: Thu, 12 Nov 2020 16:13:34 +0100 Message-ID: <20201112151334.32167-2-nuno.sa@analog.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201112151334.32167-1-nuno.sa@analog.com> References: <20201112151334.32167-1-nuno.sa@analog.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-12_06:2020-11-12,2020-11-12 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=1 spamscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 phishscore=0 mlxlogscore=926 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011120092 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Make sure that a callback is actually present before trying to call it... Signed-off-by: Nuno Sá --- drivers/iio/buffer/industrialio-buffer-cb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c index 47c96f7f4976..b4385f59399d 100644 --- a/drivers/iio/buffer/industrialio-buffer-cb.c +++ b/drivers/iio/buffer/industrialio-buffer-cb.c @@ -27,6 +27,10 @@ static struct iio_cb_buffer *buffer_to_cb_buffer(struct iio_buffer *buffer) static int iio_buffer_cb_store_to(struct iio_buffer *buffer, const void *data) { struct iio_cb_buffer *cb_buff = buffer_to_cb_buffer(buffer); + + if (!cb_buff->cb) + return 0; + return cb_buff->cb(data, cb_buff->private); }