From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by befuddled.reisers.ca (Postfix, from userid 65534) id D49271EFD1A; Tue, 20 Jun 2017 03:31:28 -0400 (EDT) Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com [IPv6:2a00:1450:400c:c09::22e]) by befuddled.reisers.ca (Postfix) with ESMTPS id 759BC1EFBC7 for ; Tue, 20 Jun 2017 03:31:26 -0400 (EDT) Received: by mail-wm0-x22e.google.com with SMTP id x70so12785649wme.0 for ; Tue, 20 Jun 2017 00:31:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=k7SKznXwlFRx9qMJGrSaSdIs/JsF6rWsKkYrje4l6WQ=; b=kaqHQHvrMcSKhNQIKrhJMC41lXKJnH1LN2TiRdBXsCQT4l07o32LPo7X/P+KABXbq0 ig957d4un5W/5BnUANNDuE5J1iBIylz4WDu7CM6XzBlDs87M1/GEborT/kyVMLaScsTI 4ArFTSCdypg2w1KXcDXkdirnnDYDhKLvEhMJnotXYpQcP6PLK7WYp3cdnMZSpRiS/Y0t uNw1eQ08TdwTCipwpAf4ZQJSbRvUJg4WAJp+yvdfdlQeZNUt8D1KnmdRB51sOwrdG+vh lFC14yPGexsa0rs/WR/ikwm7qQrxn06f699hGrpfmr7K4GPUYAdFFvyUH5hUfgJAZiXA 3L1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=k7SKznXwlFRx9qMJGrSaSdIs/JsF6rWsKkYrje4l6WQ=; b=Id9o4LMoeSlfymA0pzYaVeyCRCVIhQthjVrVs36kDYGMqX08NujweyHHlvPtmFV2PH O+wuQ5c9OO/LWOW2u5rRRHSGxV2dLiYah3GVQ3UrjqJsmVqLtBKZh1t7USiGA50IqZuQ UHhlEO5kS/7zHQt1zsxD25Qz1jD4PqN+T91T42o5+efmlcYwUrl6iAtoFVqTCfB7Gs+7 BX5IvWBrDLrkRhBqVCFnYONZZwaEMfUI1rHdqe3DXu6D1rmhXPRHeLTKfJ5qM/Y93wLW 3SG0imNgYxSzRnFolLZwVXG/e7Zhb7g9zlXakvseYFX3nsp3/iNNYb6A9BZb0rO5a9hL F0Hw== X-Gm-Message-State: AKS2vOyU5mELcYpl7SlPPQ77jnGPQi/AckDYjzo/sG6wL/v86vxEaqp2 4q3lUOKF4qEMmNLf X-Received: by 10.28.227.67 with SMTP id a64mr1552056wmh.43.1497943883253; Tue, 20 Jun 2017 00:31:23 -0700 (PDT) Received: from sanghar ([2a00:23c4:7320:5900:224:d6ff:fe76:7136]) by smtp.gmail.com with ESMTPSA id i64sm13105941wmd.33.2017.06.20.00.31.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Jun 2017 00:31:22 -0700 (PDT) Date: Tue, 20 Jun 2017 08:31:20 +0100 From: Okash Khawaja To: Samuel Thibault Cc: "Speakup is a screen review system for Linux." Subject: [patch] staging: speakup: fix synth caching when synth init fails Message-ID: <20170620073120.GA3843@sanghar> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.8.2 (2017-04-18) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 X-BeenThere: speakup@linux-speakup.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Speakup is a screen review system for Linux." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jun 2017 07:31:29 -0000 synths[] array caches currently loaded synths. synth_add checks synths[] before adding a new one. It however ignores the result of do_synth_init. So when do_synth_init fails, the failed synth is still cached. Since, as a result module loading fails too, synth_remove - which is responsible for removing the cached synth - is never called. Next time the failing synth is added again it succeeds because synth_add finds it cached inside synths[]. This patch fixes this by caching a synth only after do_synth_init succeeds. Signed-off-by: Okash Khawaja --- drivers/staging/speakup/synth.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/staging/speakup/synth.c +++ b/drivers/staging/speakup/synth.c @@ -445,10 +445,15 @@ int synth_add(struct spk_synth *in_synth mutex_unlock(&spk_mutex); return -1; } - synths[i++] = in_synth; - synths[i] = NULL; + if (in_synth->startup) status = do_synth_init(in_synth); + + if (!status) { + synths[i++] = in_synth; + synths[i] = NULL; + } + mutex_unlock(&spk_mutex); return status; }