Riley, 48, wrapped the drug in material and tried to mask the smell before hiding it in her bra to avoid detection on a visit to Armley jail in Leeds, West Yorks.
She was caught after the scent of the drug was picked up by sniffer dogs at the prison on June 4 this year.
Handing Riley a suspended prison sentence at Leeds Crown Court, Recorder Mark Cran QC told her: "Unfortunately for you the prison dogs are impervious to perfume."
Riley, from Wakefield, had around 25 pounds worth of cannabis on her at the time of her arrest.
The court heard she was intending to pass the drug onto her eldest son who had been on remand for six months, awaiting trial for burglary.
Louise Pryke told the court her son had since been acquitted of the allegation after the trial was halted due to unreliable evidence.
Riley pleaded guilty to conveying a prohibited article into prison. She was given an eight-month prison sentence, suspended for one year.
She was also ordered to do 100 hours unpaid work and take part in an activity programme designed to address her offending.
James Littlehayles, mitigating, said Riley, who has convictions for minor offences including drink driving, did not commit the offence for financial gain and had not abused a position of trust.
The court heard Riley has two other children, including a younger son who was suffering from serious health problem, who would suffer greatly if she was sent to prison.
Recorder Cran told Riley there were significant mitigating factors which enabled him not to send her to prison. He said: "You accept that your behaviour was very foolish indeed. You need to be with your son and 11-year-old daughter."