From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755977AbdKCObW (ORCPT ); Fri, 3 Nov 2017 10:31:22 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:49220 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752296AbdKCObP (ORCPT ); Fri, 3 Nov 2017 10:31:15 -0400 X-Google-Smtp-Source: ABhQp+T2rW8a0DJ+u+oHDdWqvEyRQ72sQJIEl2OLH79MpaDzaJlgxM+D9I5Cv6vZeF8QSVeFl9D9oA== From: Johan Hovold To: Rob Herring Cc: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 2/8] serdev: fix receive_buf return value when no callback Date: Fri, 3 Nov 2017 15:30:53 +0100 Message-Id: <20171103143059.20749-3-johan@kernel.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171103143059.20749-1-johan@kernel.org> References: <20171103143059.20749-1-johan@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The receive_buf callback is supposed to return the number of bytes processed and should specifically not return a negative errno. Due to missing sanity checks in the serdev tty-port controller, a driver not providing a receive_buf callback could cause the flush_to_ldisc() worker to spin in a tight loop when the tty buffer pointers are incremented with -EINVAL (-22). The missing sanity checks have now been added to the tty-port controller, but let's fix up the serdev-controller helper as well. Signed-off-by: Johan Hovold --- include/linux/serdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/serdev.h b/include/linux/serdev.h index e69402d4a8ae..d609e6dc5bad 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -184,7 +184,7 @@ static inline int serdev_controller_receive_buf(struct serdev_controller *ctrl, struct serdev_device *serdev = ctrl->serdev; if (!serdev || !serdev->ops->receive_buf) - return -EINVAL; + return 0; return serdev->ops->receive_buf(serdev, data, count); } -- 2.15.0