Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1151454imm; Wed, 1 Aug 2018 11:02:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeKy4XQqLlF7FU/s0G7ztzDdMAD3gIadkIlQLQBW0Cq3+N1+NvUnzd38daruDJW8hNaKtUo X-Received: by 2002:a17:902:aa07:: with SMTP id be7-v6mr25342201plb.109.1533146550318; Wed, 01 Aug 2018 11:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146550; cv=none; d=google.com; s=arc-20160816; b=FF+NX57Lgf8Wctgm3lbbf2hPT3pn0cF5LaH8MDUmjxsaJllN+hIKv+Gvd8Q+XoJ2Rx /hKNPebKMHITHwGfRxn/jZ4RWzF1c2uCPGuJogGBlGh7Jf/lFOhEMVbBuBNEYAltYLw1 qlXG8esmL/FmHn2qukRrIz5l0bk0+dB2IIm0DueuTDf9PmuEi2Yj9Hg53YRTxTzc77pQ t/4po0EROtFESwfwTiFGRdxk4+1hLQV8+X/+Jv2yzWEfkJMZ/WjTb7cbzdzGVUQowHOz LoS/YCfEevNBBY91ely+Te40Kw8SwzA/M3Y6q9SzJpQm+4zTlXmpCuuOp+5o+eYd/i5S 8QpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=bLNDLIEQOC4WbxMRCWE8ful4622xV1BouBoxqZ71Qyc=; b=ao+VHJ0qUNl7VxvEtrBJ5Me+wRMGl9zKlVFv5v38GS2lxUFdltIcxpMCazXQ6KbdHc yrMnPVJHxZ+0k5/ZNCpHAIvNW9n2tn9gb3K4FT3B3i052N9N4LuzxluMIKQNuFqa8EwJ 7C7gqh9ma7nUhOT9iE/glVHii0cgTLhyxAKX7mQHBbOXA9lgMoyWRK/c+2465TKPqeYz wSzeaZHpCsHplaxryf5XAC6J+AzGOruxDExutc4Kus3D+2veyFnjWiqEZXri2V3S+3Vv 4fHkZo4Nb7WtiMKgq6pvKzte/kn68BATPRSd8nzAJtIRyIQ6kOIGVVHOdDdy2iAULAzI dBzg== 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 25-v6si18240558pgk.438.2018.08.01.11.02.15; Wed, 01 Aug 2018 11:02:30 -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 S1731991AbeHATrk (ORCPT + 99 others); Wed, 1 Aug 2018 15:47:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49794 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405886AbeHATIi (ORCPT ); Wed, 1 Aug 2018 15:08:38 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 966A31359; Wed, 1 Aug 2018 17:13:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandre Belloni , Sasha Levin Subject: [PATCH 4.14 035/246] rtc: ensure rtc_set_alarm fails when alarms are not supported Date: Wed, 1 Aug 2018 18:49:05 +0200 Message-Id: <20180801165013.358210187@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexandre Belloni [ Upstream commit abfdff44bc38e9e2ef7929f633fb8462632299d4 ] When using RTC_ALM_SET or RTC_WKALM_SET with rtc_wkalrm.enabled not set, rtc_timer_enqueue() is not called and rtc_set_alarm() may succeed but the subsequent RTC_AIE_ON ioctl will fail. RTC_ALM_READ would also fail in that case. Ensure rtc_set_alarm() fails when alarms are not supported to avoid letting programs think the alarms are working for a particular RTC when they are not. Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/interface.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -359,6 +359,11 @@ int rtc_set_alarm(struct rtc_device *rtc { int err; + if (!rtc->ops) + return -ENODEV; + else if (!rtc->ops->set_alarm) + return -EINVAL; + err = rtc_valid_tm(&alarm->time); if (err != 0) return err;