From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by befuddled.reisers.ca (Postfix, from userid 65534) id AB1E41F0366; Tue, 20 Jun 2017 06:07:44 -0400 (EDT) Received: from mail-wr0-x231.google.com (mail-wr0-x231.google.com [IPv6:2a00:1450:400c:c0c::231]) by befuddled.reisers.ca (Postfix) with ESMTPS id 4B1DE1EFF94 for ; Tue, 20 Jun 2017 06:07:39 -0400 (EDT) Received: by mail-wr0-x231.google.com with SMTP id c11so33401380wrc.3 for ; Tue, 20 Jun 2017 03:07:39 -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=pjcjCjM3+cPTbgyHKKpuhOlx3mbnfIzGEUc/IzRzasg=; b=Ur2o2cRtkaxYF5g/9O1SsToAAvt8G1n5eNQ9VDaJm1FZRPpxs9uxS/g3OCM3puFYQh a1OsL4kvGuzpXseYZyKqIwEEJYH0ozNXRgktcicKqJa8CTmgSUUzAQY2jfpG239wP+nw UhmehKbB6pdh1SxcGlYgJn0IcZAsSt5xKapZPBNI7Ro1qRYOTIYvv5FF8yg1Kvw/iuV7 eJrRRlvrqog1u9ZYwRUgkd/Nwt6Tk17d49C8zSxNhBrY/01NdHIO+0pTsziU2VsuL2rz ahvEnBaCi1edI9ZRS/UePeDifcPwDCAQMRMd2t01THCf1K06G8b9mxdcHwYxTUcOWw8U 8NKg== 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=pjcjCjM3+cPTbgyHKKpuhOlx3mbnfIzGEUc/IzRzasg=; b=GkcTTO5TFWpGn3Uwvc8+zAV1r0A/dygyEV7qTCW1qRVVAZqhh5/7KBfypCnNT1dQlO i63eAHRqHU8IHEudEFpzh6oKCsuEwNHRPJYCP5xuxfsRZjGIsq7bJbOX2GlqmOqlSwSh wD/13vqQe9x8ZjuwDGYeY9QJv+rTrTT20H7H7tCjPTNrmYqhfScgWjFvPs4Vt0fb8XjU qcj0NBjaRB0DeAZv09tdquNzHG+GR46OxtrlzLyhy4dK1GixHf669EcaEaIiNj6UUofj r4hLU4PryxH5u0RyI0NMy7ZRJ8CCLkUaWBQTxUjTHm+mKOB6MRVG82Bh0Eh9w0x/zJcf 9kRA== X-Gm-Message-State: AKS2vOwj6wipjFCs6OmxjY5XZ1U/FGOly3bLzCSn+2j79v4JYfX1z/H/ UK1kL/mhd2BfXg== X-Received: by 10.223.172.231 with SMTP id o94mr19527384wrc.201.1497953255731; Tue, 20 Jun 2017 03:07:35 -0700 (PDT) Received: from sanghar ([2a00:23c4:7320:5900:224:d6ff:fe76:7136]) by smtp.gmail.com with ESMTPSA id k12sm12836287wrc.10.2017.06.20.03.07.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Jun 2017 03:07:34 -0700 (PDT) Date: Tue, 20 Jun 2017 11:07:32 +0100 From: Okash Khawaja To: Greg Kroah-Hartman , Samuel Thibault , linux-kernel@vger.kernel.org Cc: William Hubbs , Chris Brannon , Kirk Reiser , speakup@linux-speakup.org, devel@driverdev.osuosl.org Subject: [patch] staging: speakup: fix synth caching when synth init fails Message-ID: <20170620100732.GA14236@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 10:07:44 -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 Reviewed-by: Samuel Thibault --- 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; }